Created
April 13, 2017 14:22
-
-
Save Evanto/b61f110e88a8f420d79827a682988b50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @page = Page.last %> | |
<% t = @page.hours.to_i * 60 + @page.minutes.to_i %> | |
<% hour, t = t.divmod(60) %> | |
<%= "%02d:%02d" % [hour, t] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @page = Page.last %> | |
<% t = @page.hours.to_i * 60 + @page.minutes.to_i %> | |
<% hour, t = t.divmod(60) %> | |
<%= "%02d:%02d" % [hour, t] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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