dtg 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dtg.rb +24 -0
- data/lib/dtg/active_support/time_with_zone_ext.rb +0 -19
- data/lib/dtg/time_ext.rb +0 -19
- data/lib/dtg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d56074244f86fd246714de4f7827abfce02be31de2bc93e659311b9e08404a
|
4
|
+
data.tar.gz: d83417f20621befc87d12f8a26d165b655fc23192a05d3aa938ae81cf39cb816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e11bf743407ad275537cfd943e02e5aa280179a7524f059274260d58a91b42f41f7706c4816d4e03f54eab6487732381fec7cf621bfff639e0f53cc27097af2b
|
7
|
+
data.tar.gz: 97a53b9db182dfed337c9a996787934e9b6d634307717dae460ef2eb81117bef0a1e7024faa21b2ea48aecc4a7bc5f160f6b93df68a6b3d4feb20f5c56d30d02
|
data/lib/dtg.rb
CHANGED
@@ -5,7 +5,31 @@ require "dtg/time_ext"
|
|
5
5
|
require "dtg/active_support/time_with_zone_ext"
|
6
6
|
|
7
7
|
module Dtg
|
8
|
+
# Zones module has timezones (UTC_Zones) as dtg listings
|
9
|
+
include Zones
|
10
|
+
|
11
|
+
# DTG Test to determine if was injected properly into class
|
8
12
|
def dtg
|
9
13
|
"DTG gem is natively integrated with this class: #{self.class}"
|
10
14
|
end
|
15
|
+
|
16
|
+
# Convert the object to the proper zone and then format as dtg in zone
|
17
|
+
def to_dtg(zone = :z)
|
18
|
+
convert(zone).format(zone)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Format the object into specified zone (as dtg)
|
22
|
+
def format(zone = :z)
|
23
|
+
key = zone.downcase.to_sym
|
24
|
+
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
25
|
+
dtg = "%d%H%M#{key.upcase.to_s} %b %y"
|
26
|
+
strftime(dtg)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Convert the object into the proper zone specified
|
30
|
+
def convert(zone = :z)
|
31
|
+
key = zone.downcase.to_sym
|
32
|
+
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
33
|
+
key == :j ? self.dup : self.in_time_zone(UTC_ZONES[key])
|
34
|
+
end
|
11
35
|
end
|
@@ -1,24 +1,5 @@
|
|
1
1
|
require 'dtg'
|
2
|
-
require_relative '../zones'
|
3
2
|
|
4
3
|
class ActiveSupport::TimeWithZone
|
5
4
|
include Dtg
|
6
|
-
include Zones
|
7
|
-
|
8
|
-
def to_dtg(zone = :z)
|
9
|
-
convert(zone).format(zone)
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(zone = :z)
|
13
|
-
key = zone.downcase.to_sym
|
14
|
-
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
15
|
-
dtg = "%d%H%M#{key.upcase.to_s} %b %y"
|
16
|
-
strftime(dtg)
|
17
|
-
end
|
18
|
-
|
19
|
-
def convert(zone = :z)
|
20
|
-
key = zone.downcase.to_sym
|
21
|
-
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
22
|
-
key == :j ? self.dup : self.in_time_zone(UTC_ZONES[key])
|
23
|
-
end
|
24
5
|
end
|
data/lib/dtg/time_ext.rb
CHANGED
@@ -1,24 +1,5 @@
|
|
1
1
|
require 'dtg'
|
2
|
-
require_relative 'zones'
|
3
2
|
|
4
3
|
class Time
|
5
4
|
include Dtg
|
6
|
-
include Zones
|
7
|
-
|
8
|
-
def to_dtg(zone = :z)
|
9
|
-
convert(zone).format(zone)
|
10
|
-
end
|
11
|
-
|
12
|
-
def format(zone = :z)
|
13
|
-
key = zone.downcase.to_sym
|
14
|
-
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
15
|
-
dtg = "%d%H%M#{key.upcase.to_s} %b %y"
|
16
|
-
strftime(dtg)
|
17
|
-
end
|
18
|
-
|
19
|
-
def convert(zone = :z)
|
20
|
-
key = zone.downcase.to_sym
|
21
|
-
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(key)
|
22
|
-
key == :j ? self.dup : self.in_time_zone(UTC_ZONES[key])
|
23
|
-
end
|
24
5
|
end
|
data/lib/dtg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SolarisFlare
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|