-
-
Save raganwald/3976679 to your computer and use it in GitHub Desktop.
Date Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Store | |
constructor: () -> | |
@services = [] | |
@reservations = [] | |
@requests = [] | |
class Service | |
constructor: (@name, @time) -> | |
class Request | |
constructor: (@date, @services) -> | |
class Reservation | |
constructor: (@start, @finish, @service) -> | |
store = new Store() | |
store.services.push(new Service("Corte", 30)) | |
store.services.push(new Service("Manicura", 30)) | |
request = new Request(new Date(), [store.services[0], store.services[1]]) | |
store.requests.push(request) | |
# This is where it breaks | |
makeReservation = (request) -> | |
date = request.date | |
mins = request.date.getMinutes() | |
mins_offSet = 0 | |
for service in request.services | |
date.setMinutes(mins + service.time + mins_offSet) | |
finish_date = new Date(date) | |
store.reservations.push(new Reservation(request.date, finish_date, service)) | |
mins_offSet += service.time | |
makeReservation(request) | |
[first, second] = store.reservations | |
console.log first.finish instanceof Date and second.finish instanceof Date | |
console.log first.finish.getTime() isnt second.finish.getTime() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment