Module: Dtg
- Includes:
- Zones
- Included in:
- ActiveSupport::TimeWithZone, DateTime, Time
- Defined in:
- lib/dtg.rb,
lib/dtg/railtie.rb,
lib/dtg/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
DTG version of gem
"3.0.2"
Constants included from Zones
Instance Method Summary collapse
-
#convert(zone = :z) ⇒ Object
Convert the object into the proper zone specified.
-
#dtg ⇒ Object
DTG Test to determine if was injected properly into class.
-
#format(zone = :z) ⇒ Object
Format the object into specified zone (as dtg).
-
#to_dtg(zone = :z) ⇒ Object
Convert the object to the proper zone and then format as dtg in zone.
Instance Method Details
#convert(zone = :z) ⇒ Object
Convert the object into the proper zone specified
30 31 32 33 34 |
# File 'lib/dtg.rb', line 30 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 |
#dtg ⇒ Object
DTG Test to determine if was injected properly into class
12 13 14 |
# File 'lib/dtg.rb', line 12 def dtg "DTG gem is natively integrated with this class: #{self.class}" end |
#format(zone = :z) ⇒ Object
Format the object into specified zone (as dtg)
22 23 24 25 26 27 |
# File 'lib/dtg.rb', line 22 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
Convert the object to the proper zone and then format as dtg in zone
17 18 19 |
# File 'lib/dtg.rb', line 17 def to_dtg(zone = :z) convert(zone).format(zone) end |