Skip to content

Instantly share code, notes, and snippets.

@thejohnnybot
Created October 29, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thejohnnybot/3976278 to your computer and use it in GitHub Desktop.
Save thejohnnybot/3976278 to your computer and use it in GitHub Desktop.
Date Issue
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
total_time = mins + service.time + mins_offSet
c_hours = 0
if total_time >= 60
console.log c_mins = Math.ceil(total_time % 60)
console.log c_hours = Math.ceil(total_time / 60)
console.log finish = date.setHours(c_hours, c_mins)
mins_offSet += service.time
makeReservation(request)
console.log store.reservations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment