Skip to content

Instantly share code, notes, and snippets.

@janv
Created January 18, 2011 21:51
Show Gist options
  • Save janv/785233 to your computer and use it in GitHub Desktop.
Save janv/785233 to your computer and use it in GitHub Desktop.
time_select = (time_str) ->
time_str = time_str.match /(\d+):(\d+)/
if (time_str)
[h, m] = time_str[1..2]
hour_options = for hour in [0...24]
hour_s = if hour < 10 then "0#{hour}" else hour
"<option #{if hour == h then 'selected' else ''}>#{hour_s}</option>" # TODO Coffee == -> === macht wahrscheinlich stress
minute_options = for minute in [0...60]
minute_s = if minute < 10 then "0#{minute}" else minute
"<option #{if minute == m then 'selected' else ''}>#{minute_s}</option>"
'''
<select class="time_h">
#{hour_options.join('')}
</select>:<select class="time_m">
#{minute_options.join('')}
</select>
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment