class Biz::Time

Constants

BIG_BANG
DAY_HOURS
DAY_MINUTES
DAY_SECONDS
HEAT_DEATH
HOUR_MINUTES
HOUR_SECONDS
MINUTE_SECONDS
WEEK_DAYS
WEEK_MINUTES

Attributes

time_zone[R]

Public Class Methods

big_bang() click to toggle source
# File lib/biz/time.rb, line 63
def self.big_bang
  BIG_BANG
end
day_hours() click to toggle source
# File lib/biz/time.rb, line 39
def self.day_hours
  DAY_HOURS
end
day_minutes() click to toggle source
# File lib/biz/time.rb, line 55
def self.day_minutes
  DAY_MINUTES
end
day_seconds() click to toggle source
# File lib/biz/time.rb, line 51
def self.day_seconds
  DAY_SECONDS
end
heat_death() click to toggle source
# File lib/biz/time.rb, line 67
def self.heat_death
  HEAT_DEATH
end
hour_minutes() click to toggle source
# File lib/biz/time.rb, line 35
def self.hour_minutes
  HOUR_MINUTES
end
hour_seconds() click to toggle source
# File lib/biz/time.rb, line 47
def self.hour_seconds
  HOUR_SECONDS
end
minute_seconds() click to toggle source
# File lib/biz/time.rb, line 31
def self.minute_seconds
  MINUTE_SECONDS
end
new(time_zone) click to toggle source
# File lib/biz/time.rb, line 71
def initialize(time_zone)
  @time_zone = time_zone
end
week_days() click to toggle source
# File lib/biz/time.rb, line 43
def self.week_days
  WEEK_DAYS
end
week_minutes() click to toggle source
# File lib/biz/time.rb, line 59
def self.week_minutes
  WEEK_MINUTES
end

Public Instance Methods

during_week(week, week_time) click to toggle source
# 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) click to toggle source
# File lib/biz/time.rb, line 75
def local(time)
  time_zone.utc_to_local(time.utc)
end
on_date(date, day_time) click to toggle source
# 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