OnTime is a dependency-less, thread-safe, and fluent way to create times in ruby.
Add this line to your application's Gemfile:
gem 'ontime'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ontime
On.January(3.rd)
On.March(24.th, 2007)
On.December(2.nd, 2008).at(1).pm
On.April(1.st).at('2:38').am
On.August(13.th).at('4:30').pm.and(56.seconds)
On.the(4.th).of(:July, 2015).at(2).pm.in('US/Pacific')
On.the(7.th).at(:midnight)
On.September(19.th).at(:midday).in('UTC')
On.Month(date, year).at(hour:minutes).am/pm.and(seconds).in(timezone)
On.the(date).of(month, year).at(hour:minutes).am/pm.and(seconds).in(timezone)
Method | Description |
---|---|
to_time |
Converts the resulting OnTime object to a native ruby Time object |
month |
Returns the month as an integer (1-12) |
date |
Returns the day as an integer (1-31) |
year |
Returns the year as an integer (ex. 2007) |
hour |
Returns the hour as an integer (0-23) |
min |
Returns the minutes as an integer (0-59) |
sec |
Returns the seconds as an integer (0-60) |
offset |
Returns the timezone offset as a string (+/-HH:MM, ex. -06:00) |
The implementation for timezone offset lookup depends on the UNIX utility
zdump
, and is not a super-robust implementation.
- Fork it (https://github.com/nathanielwroblewski/ontime/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request