Skip to content

Instantly share code, notes, and snippets.

@natchiketa
Last active August 29, 2015 14:05
Show Gist options
  • Save natchiketa/2d5890dcf87cb68d85d0 to your computer and use it in GitHub Desktop.
Save natchiketa/2d5890dcf87cb68d85d0 to your computer and use it in GitHub Desktop.
Create time range in minute increments w/Lo-Dash and time.js
# Requires Lo-Dash and zever/time.js
timeFromMinutes = (mins) ->
Time ("#{((if mins < 780 then ~~(mins / 60) else (~~(mins / 60) - 12)))}:#{mins % 60} ")
.replace(/:0 /, ":00 #{if mins >= 720 then 'PM' else 'AM'}")
minuteIncrements = (range) ->
_.map range, (mins) ->
timeFromMinutes mins
minuteIncrements _.range(540, 1260, 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment