class Date

This class contains Date extensions used by SG

Constants

SG_TIME_OFFSET

Public Instance Methods

beginning_of_sg_day(time_zone) click to toggle source
# File lib/sg_common/core_ext/date/sg_date.rb, line 12
def beginning_of_sg_day(time_zone)
  timezone = TZInfo::Timezone.get(time_zone)

  timezone.local_to_utc(Time.local(year, month, day, SG_TIME_OFFSET, 0, 0, 0))
end
dt() click to toggle source
# File lib/sg_common/core_ext/date/sg_date.rb, line 26
def dt
  strftime('%Y%m%d')
end
end_of_sg_day(time_zone) click to toggle source
# File lib/sg_common/core_ext/date/sg_date.rb, line 18
def end_of_sg_day(time_zone)
  (self + 1.day).beginning_of_sg_day(time_zone)
end
hours_in_sg_day(time_zone) click to toggle source
# File lib/sg_common/core_ext/date/sg_date.rb, line 22
def hours_in_sg_day(time_zone)
  ((end_of_sg_day(time_zone) - beginning_of_sg_day(time_zone)) / 1.hour).round
end
utc_time_offset(time_zone) click to toggle source
# File lib/sg_common/core_ext/date/sg_date.rb, line 8
def utc_time_offset(time_zone)
  (self.beginning_of_sg_day(time_zone) - self.to_time(:utc).midnight) / 3600
end