Class: Biz::Time
- Inherits:
-
Object
- Object
- Biz::Time
- Defined in:
- lib/biz/time.rb
Class Method Summary collapse
- .big_bang ⇒ Object
- .day_hours ⇒ Object
- .day_minutes ⇒ Object
- .day_seconds ⇒ Object
- .heat_death ⇒ Object
- .hour_minutes ⇒ Object
- .hour_seconds ⇒ Object
- .minute_seconds ⇒ Object
- .week_days ⇒ Object
- .week_minutes ⇒ Object
Instance Method Summary collapse
- #during_week(week, week_time) ⇒ Object
-
#initialize(time_zone) ⇒ Time
constructor
A new instance of Time.
- #local(time) ⇒ Object
- #on_date(date, day_time) ⇒ Object
Constructor Details
#initialize(time_zone) ⇒ Time
Returns a new instance of Time.
71 72 73 |
# File 'lib/biz/time.rb', line 71 def initialize(time_zone) @time_zone = time_zone end |
Class Method Details
.big_bang ⇒ Object
63 64 65 |
# File 'lib/biz/time.rb', line 63 def self.big_bang BIG_BANG end |
.day_hours ⇒ Object
39 40 41 |
# File 'lib/biz/time.rb', line 39 def self.day_hours DAY_HOURS end |
.day_minutes ⇒ Object
55 56 57 |
# File 'lib/biz/time.rb', line 55 def self.day_minutes DAY_MINUTES end |
.day_seconds ⇒ Object
51 52 53 |
# File 'lib/biz/time.rb', line 51 def self.day_seconds DAY_SECONDS end |
.heat_death ⇒ Object
67 68 69 |
# File 'lib/biz/time.rb', line 67 def self.heat_death HEAT_DEATH end |
.hour_minutes ⇒ Object
35 36 37 |
# File 'lib/biz/time.rb', line 35 def self.hour_minutes HOUR_MINUTES end |
.hour_seconds ⇒ Object
47 48 49 |
# File 'lib/biz/time.rb', line 47 def self.hour_seconds HOUR_SECONDS end |
.minute_seconds ⇒ Object
31 32 33 |
# File 'lib/biz/time.rb', line 31 def self.minute_seconds MINUTE_SECONDS end |
.week_days ⇒ Object
43 44 45 |
# File 'lib/biz/time.rb', line 43 def self.week_days WEEK_DAYS end |
.week_minutes ⇒ Object
59 60 61 |
# File 'lib/biz/time.rb', line 59 def self.week_minutes WEEK_MINUTES end |
Instance Method Details
#during_week(week, week_time) ⇒ Object
95 96 97 |
# File 'lib/biz/time.rb', line 95 def during_week(week, week_time) on_date(week.start_date + week_time.wday, week_time.day_time) end |
#local(time) ⇒ Object
75 76 77 |
# File 'lib/biz/time.rb', line 75 def local(time) time_zone.utc_to_local(time.utc) end |
#on_date(date, day_time) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/biz/time.rb', line 79 def on_date(date, day_time) time_zone.local_to_utc( ::Time.new( date.year, date.month, date.mday, day_time.hour, day_time.minute, day_time.second ), true ) rescue TZInfo::PeriodNotFound on_date(Date.for_dst(date, day_time), day_time.for_dst) end |