Class: DateTime

Inherits:
Object
  • Object
show all
Includes:
Dtg, Zones
Defined in:
lib/dtg/date_time_ext.rb

Constant Summary

Constants included from Zones

Zones::UTC_ZONES

Constants included from Dtg

Dtg::VERSION

Instance Method Summary collapse

Methods included from Dtg

#dtg

Instance Method Details

#convert(zone = :z) ⇒ Object



19
20
21
22
23
# File 'lib/dtg/date_time_ext.rb', line 19

def convert(zone = :z)
  key = zone.downcase.to_sym
  raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
  key == :j ? self.dup : self.in_time_zone(UTC_ZONES[key])
end

#format(zone = :z) ⇒ Object



12
13
14
15
16
17
# File 'lib/dtg/date_time_ext.rb', line 12

def format(zone = :z)
  key = zone.downcase.to_sym
  raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
  dtg = "%d%H%M#{key.upcase.to_s} %b %y"
  strftime(dtg)
end

#to_dtg(zone = :z) ⇒ Object



8
9
10
# File 'lib/dtg/date_time_ext.rb', line 8

def to_dtg(zone = :z)
  convert(zone).format(zone)
end