Skip to content

Instantly share code, notes, and snippets.

@Evanto
Created April 13, 2017 14:22
Show Gist options
  • Save Evanto/b61f110e88a8f420d79827a682988b50 to your computer and use it in GitHub Desktop.
Save Evanto/b61f110e88a8f420d79827a682988b50 to your computer and use it in GitHub Desktop.
<% @page = Page.last %>
<% t = @page.hours.to_i * 60 + @page.minutes.to_i %>
<% hour, t = t.divmod(60) %>
<%= "%02d:%02d" % [hour, t] %>
<% @page = Page.last %>
<% t = @page.hours.to_i * 60 + @page.minutes.to_i %>
<% hour, t = t.divmod(60) %>
<%= "%02d:%02d" % [hour, t] %>
midnight = Time.new.at_beginning_of_day # => 2017-04-12 00:00:00 +0300
time_sleep = midnight + 18.hours + 30.minutes # => 2017-04-12 18:30:00 +0300
time_wake_up = time_sleep + 8.hours # => 2017-04-13 02:30:00 +0300
time_wake_up.hour # => 2
time_wake_up.min # => 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment