This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
forked from zenhob/hcl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow an initial time to be specified when starting a timer, closes z…
- Loading branch information
Zack Hobson
committed
Jul 30, 2009
1 parent
31a3a51
commit d2de12e
Showing
5 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class HCl | ||
module Utility | ||
# Convert from decimal to a string of the form HH:MM. | ||
def as_hours hours | ||
minutes = hours.to_f * 60.0 | ||
sprintf "%d:%02d", (minutes / 60).to_i, (minutes % 60).to_i | ||
end | ||
|
||
def time2float time_string | ||
if time_string =~ /:/ | ||
hours, minutes = time_string.split(':') | ||
hours.to_f + (minutes.to_f / 60.0) | ||
elsif time_string =~ /./ | ||
time_string.to_f | ||
end | ||
end | ||
end | ||
end |