Skip to content

Instantly share code, notes, and snippets.

@taher435
Created November 5, 2015 11:46
Show Gist options
  • Select an option

  • Save taher435/972f3f9db117148e8b53 to your computer and use it in GitHub Desktop.

Select an option

Save taher435/972f3f9db117148e8b53 to your computer and use it in GitHub Desktop.
Create time drop down with customisable interval
def time_iterate(start_time, end_time, step, &block)
begin
yield(start_time)
end while (start_time += step) <= end_time
end
start_time = Time.parse("2010/1/1")
end_time = Time.parse("2010/1/2")
time_iterate(start_time, end_time, 1800) do |t|
hours.push({:text => t.strftime("%H:%M"), :hour => t.hour})
end
@taher435

taher435 commented Nov 5, 2015

Copy link
Copy Markdown
Author

time drop down with intervals in ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment