dtg 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +141 -3
- data/Rakefile +6 -7
- data/lib/dtg.rb +7 -2
- data/lib/dtg/core_datetime_ext.rb +22 -0
- data/lib/dtg/core_time_ext.rb +22 -0
- data/lib/dtg/core_timewithzone_ext.rb +22 -0
- data/lib/dtg/version.rb +1 -1
- data/lib/dtg/zones.rb +56 -0
- metadata +26 -9
- data/lib/dtg/core_ext.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d41d3d30878513e54ace3d7449ba59abad4f24cc4c675f051fb50dfb17be92b9
|
4
|
+
data.tar.gz: c4c0f569d96219b6547310def9e4f3bc430a9628204467d7dbecc7e555aaa2c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaf842f9354b842328f0d7c6566969a1be7c100219045dad016ce71b22fdb3c6acc3e21e6db7c079d8d6f321381b5b0647edb80222a5579d30544e1efd9c3351
|
7
|
+
data.tar.gz: 1e8f778551ed82d62b6a8be5d8d7dda7e4d53aa057c5703c61e8cabf57cf05fbe8cf7290ec49f92393e35dabf8611291b03b5c4900c76ca23c0953455fb6c3d6
|
data/README.md
CHANGED
@@ -1,13 +1,85 @@
|
|
1
1
|
[![GitHub version](https://badge.fury.io/gh/SolarisFlare%2Fdtg.svg)](https://badge.fury.io/gh/SolarisFlare%2Fdtg)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/dtg.svg)](https://badge.fury.io/rb/dtg)
|
2
3
|
[![Build Status](https://travis-ci.org/SolarisFlare/dtg.svg?branch=master)](https://travis-ci.org/SolarisFlare/dtg)
|
3
4
|
|
4
5
|
# Dtg
|
5
|
-
|
6
|
+
|
7
|
+
DTG is a ruby gem to convert Time objects into DTG format.
|
8
|
+
|
9
|
+
A DTG is a DateTimeGroup which is used in the military to save time. DTG are saved in the format DDHHMML MMM YY, where D is day, H is hour, L is letter, M is month, and Y is year. The Month is the 3 character representation such as JAN for January, MAY for May, DEC for December and so on. Year is only the last two digits of the year e.g. 2019 is just 19. The letter is the zone code such as W for whiskey which is HST, Z for zulu which is GMT, A-Z are the zones used.
|
10
|
+
|
11
|
+
DTG integrates natively with the DateTime, Time, and ActiveSupport::TimeWithZone classes in Ruby/Rails and is callable on all Time objects. DTG returns a visually formatted dtg converted based on knolwedge of the zone of the object and the intended zone. It is also respective of daylight savings time of your objects zone and its intended zone.
|
12
|
+
|
13
|
+
DTG is the military acronym referring to what is also called nautical or maritime time zones. These zones are mapped across the world from A-Z not including J as J references the local timezone of yourself.
|
14
|
+
|
15
|
+
## Table of Contents
|
16
|
+
|
17
|
+
1. [DTG](#dtg)
|
18
|
+
2. [Table of Contents](#table-of-contents)
|
19
|
+
3. [Usage](#usage)
|
20
|
+
1. [DTG Zones](#dtg-zones)
|
21
|
+
2. [DTG Zone Map](#dtg-zone-map)
|
22
|
+
4. [Installation](#installation)
|
23
|
+
5. [Testing](#testing)
|
24
|
+
6. [Problems](#problems)
|
25
|
+
7. [Contributing](#contributing)
|
26
|
+
8. [License](#license)
|
6
27
|
|
7
28
|
## Usage
|
8
|
-
|
29
|
+
|
30
|
+
DTG implements the method to_dtg into the Time class and is fully compatible with all Time objects(DateTime, Time, and TimeWithZone have been tested, custom objects should also function the same as long as their properties emulate that of the former).
|
31
|
+
|
32
|
+
To use:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
TIMEOBJECT.to_dtg
|
36
|
+
```
|
37
|
+
|
38
|
+
and it will return the time object as a string in the zulu timezone in dtg format.
|
39
|
+
|
40
|
+
For other DTG formats:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
TIMEOBJECT.to_dtg(:zone)
|
44
|
+
```
|
45
|
+
|
46
|
+
where zone is any single letter symbol A-Z, capital or lower case and it will return the time object as a string in the zone format.
|
47
|
+
|
48
|
+
### DTG Zones
|
49
|
+
|
50
|
+
- A: Alpha Time: UTC +01:00 (Paris, France)
|
51
|
+
- B: Bravo Time: UTC +02:00 (Athens, Greece)
|
52
|
+
- C: Charlie Time: UTC +03:00 (Moscow, Russia)
|
53
|
+
- D: Delta Time: UTC +04:00 (Kabul, Afghanistan)
|
54
|
+
- E: Echo Time: UTC +05:00 (New Delhi, India)
|
55
|
+
- F: Foxtrot Time: UTC +06:00 (Dhanka, Bangladesh)
|
56
|
+
- G: Golf Time: UTC +07:00 (Bangkok, Thailand)
|
57
|
+
- H: Hotel Time: UTC +08:00 (Beijing, China)
|
58
|
+
- I: India Time: UTC +09:00 (Tokyo, Japan)
|
59
|
+
- J: Juliet Time: (Local Time Zone)
|
60
|
+
- K: Kilo Time: UTC +10:00 (Sydney, Australia)
|
61
|
+
- L: Lima Time: UTC +11:00 (Honiara, Solomon Islands)
|
62
|
+
- M: Mike Time: UTC +12:00 (Wellington, New Zealand)
|
63
|
+
- N: November Time: UTC -01:00 (Azores)
|
64
|
+
- O: Oscar Time: UTC -02:00 (Gothab, Greenland)
|
65
|
+
- P: Papa Time: UTC -03:00 (Buenos Aires, Argentina)
|
66
|
+
- Q: Quebec Time: UTC -04:00 (Halifax, Nova Scotia)
|
67
|
+
- R: Romeo Time: UTC -05:00 (New York, NY United States)
|
68
|
+
- S: Sierra Time: UTC -06:00 (Dallas, TX United States)
|
69
|
+
- T: Tango Time: UTC -07:00 (Denver, CO United States)
|
70
|
+
- U: Uniform Time: UTC -08:00 (Los Angeles, CA United States)
|
71
|
+
- V: Victor Time: UTC -09:00 (Juneau, AK United States)
|
72
|
+
- W: Whiskey Time: UTC -10:00 (Honolulu, HI United States)
|
73
|
+
- X: X-Ray Time: UTC -11:00 (Nome, AK United States)
|
74
|
+
- Y: Yankee Time: UTC -12:00 (Suva, Fiji)
|
75
|
+
- Z: Zulu Time: UTC +-00:00 (Greenwich, England)
|
76
|
+
|
77
|
+
### DTG Zone Map
|
78
|
+
|
79
|
+
![DTG zones displayed across the map with their offsets](dtg_zones.png?raw=true "DTG Zones")
|
9
80
|
|
10
81
|
## Installation
|
82
|
+
|
11
83
|
Add this line to your application's Gemfile:
|
12
84
|
|
13
85
|
```ruby
|
@@ -24,8 +96,74 @@ Or install it yourself as:
|
|
24
96
|
$ gem install dtg
|
25
97
|
```
|
26
98
|
|
99
|
+
## Testing
|
100
|
+
|
101
|
+
If you would like to test this gem before adding it to your project to see it's functionality, follow these steps:
|
102
|
+
|
103
|
+
1. Clone the repository
|
104
|
+
|
105
|
+
```sh
|
106
|
+
git clone https://github.com/SolarisFlare/dtg
|
107
|
+
```
|
108
|
+
|
109
|
+
2. cd into the test/dummy directory
|
110
|
+
|
111
|
+
3. Start the rails console
|
112
|
+
|
113
|
+
```sh
|
114
|
+
rails console
|
115
|
+
```
|
116
|
+
|
117
|
+
OR
|
118
|
+
|
119
|
+
```sh
|
120
|
+
rails c
|
121
|
+
```
|
122
|
+
|
123
|
+
4. Test away
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
#<Tested in irb console(default rails), also works in Pry console>
|
127
|
+
|
128
|
+
y = Time.zone.now
|
129
|
+
y.dtg
|
130
|
+
y = Time.zone.now.to_dtg(:j)
|
131
|
+
y
|
132
|
+
|
133
|
+
x = Time.now
|
134
|
+
x.dtg
|
135
|
+
x.to_dtg(:j)
|
136
|
+
x.to_dtg(:J)
|
137
|
+
x.to_dtg
|
138
|
+
x.to_dtg(:z)
|
139
|
+
x.to_dtg(:Z)
|
140
|
+
x.to_dtg(:W)
|
141
|
+
x.to_dtg(:m)
|
142
|
+
|
143
|
+
z = DateTime.now
|
144
|
+
z.dtg
|
145
|
+
z.to_dtg
|
146
|
+
z.convert :w
|
147
|
+
z.to_dtg :c
|
148
|
+
|
149
|
+
Time.now.to_dtg(:a)
|
150
|
+
DateTime.now.to_dtg :Q
|
151
|
+
Time.zone.now.to_dtg L.to_sym
|
152
|
+
```
|
153
|
+
|
154
|
+
> Note: The .dtg method will return a string naming the type of the object you called it on and can therefore be used to verify if the gem has successfully natively integrated with Ruby/Rails(should fail if not). I included this for testing purposes to check that the right modules were being loaded with DTG and have run into no load failures but for peace of mind I left it in in case you want to see for yourself.
|
155
|
+
|
156
|
+
## Problems
|
157
|
+
|
158
|
+
DTG relies upon time objects that have timezone set either as Time.zone or as the default offset recorded. I recommend setting the application timezone in the application.rb configuration file so that dtg works automatically on any generated time objects. TimeWithZone is different and therefore has is a Time with offset and with zone. Therefore without data loss, you can convert from TimeWithZone to DateTime or Time and maintain the same time, however, you may lose the zone code but the offset will be kept and the zone code can be recovered based on this offset but certain zones that follow daylight savings time may lose their savings-ness and will no longer spring forward or backward if converted.
|
159
|
+
|
160
|
+
> DTG currently supports the following: DateTime, Time, ActiveSupport::TimeWithZone. If you extend the Time class as does TimeWithZone, DTG may not function properly, to ensure it functions the same for TimeWithZone, I changed the conversion to_time, and then in_time_zone since ActiveSupport::TimeWithZone has strage behaviors I have not been able to understand yet. Until it is updated to be more stable or I find the proper solution, this will not affect the gems functionality, but will just be a different(slightly less efficient: calling an extra method) way to work with ActiveSupport:TimeWithZone objects.
|
161
|
+
|
162
|
+
|
27
163
|
## Contributing
|
28
|
-
|
164
|
+
|
165
|
+
If you want to contribute please let me know though either an email or you can just submit a pull request to add anything!
|
29
166
|
|
30
167
|
## License
|
168
|
+
|
31
169
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -16,12 +16,11 @@ end
|
|
16
16
|
|
17
17
|
require 'bundler/gem_tasks'
|
18
18
|
|
19
|
-
|
19
|
+
begin
|
20
|
+
require 'rspec/core/rake_task'
|
21
|
+
RSpec::Core::RakeTask.new(:spec)
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
t.verbose = false
|
23
|
+
task :default => :spec
|
24
|
+
rescue LoadError
|
25
|
+
# no rspec available
|
25
26
|
end
|
26
|
-
|
27
|
-
task default: :test
|
data/lib/dtg.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require "dtg/railtie"
|
2
|
-
require "dtg/
|
2
|
+
require "dtg/zones"
|
3
|
+
require "dtg/core_datetime_ext"
|
4
|
+
require "dtg/core_time_ext"
|
5
|
+
require "dtg/core_timewithzone_ext"
|
3
6
|
|
4
7
|
module Dtg
|
5
|
-
|
8
|
+
def dtg
|
9
|
+
"DTG gem is natively integrated with this class: #{self.class}"
|
10
|
+
end
|
6
11
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dtg'
|
2
|
+
require_relative 'zones'
|
3
|
+
|
4
|
+
class DateTime
|
5
|
+
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
|
+
dtg = "%d%H%M#{zone.upcase} %b %y"
|
14
|
+
strftime(dtg)
|
15
|
+
end
|
16
|
+
|
17
|
+
def convert(zone = :z)
|
18
|
+
zone = zone.downcase
|
19
|
+
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(zone)
|
20
|
+
zone == :j ? self : self.in_time_zone(UTC_ZONES[zone])
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dtg'
|
2
|
+
require_relative 'zones'
|
3
|
+
|
4
|
+
class Time
|
5
|
+
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
|
+
dtg = "%d%H%M#{zone.upcase} %b %y"
|
14
|
+
strftime(dtg)
|
15
|
+
end
|
16
|
+
|
17
|
+
def convert(zone = :z)
|
18
|
+
zone = zone.downcase
|
19
|
+
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(zone)
|
20
|
+
zone == :j ? self : self.in_time_zone(UTC_ZONES[zone])
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dtg'
|
2
|
+
require_relative 'zones'
|
3
|
+
|
4
|
+
class ActiveSupport::TimeWithZone
|
5
|
+
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
|
+
dtg = "%d%H%M#{zone.upcase} %b %y"
|
14
|
+
strftime(dtg)
|
15
|
+
end
|
16
|
+
|
17
|
+
def convert(zone = :z)
|
18
|
+
zone = zone.downcase
|
19
|
+
raise "Error: #{zone} is not a valid zone" unless UTC_ZONES.key?(zone)
|
20
|
+
zone == :j ? self : self.to_time.in_time_zone(UTC_ZONES[zone])
|
21
|
+
end
|
22
|
+
end
|
data/lib/dtg/version.rb
CHANGED
data/lib/dtg/zones.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Zones
|
2
|
+
UTC_ZONES = {
|
3
|
+
# A: Alpha Time: UTC +01:00 (Paris, France)
|
4
|
+
a: +1,
|
5
|
+
# B: Bravo Time: UTC +02:00 (Athens, Greece)
|
6
|
+
b: +2,
|
7
|
+
# C: Charlie Time: UTC +03:00 (Moscow, Russia)
|
8
|
+
c: +3,
|
9
|
+
# D: Delta Time: UTC +04:00 (Kabul, Afghanistan)
|
10
|
+
d: +4,
|
11
|
+
# E: Echo Time: UTC +05:00 (New Delhi, India)
|
12
|
+
e: +5,
|
13
|
+
# F: Foxtrot Time: UTC +06:00 (Dhanka, Bangladesh)
|
14
|
+
f: +6,
|
15
|
+
# G: Golf Time: UTC +07:00 (Bangkok, Thailand)
|
16
|
+
g: +7,
|
17
|
+
# H: Hotel Time: UTC +08:00 (Beijing, China)
|
18
|
+
h: +8,
|
19
|
+
# I: India Time: UTC +09:00 (Tokyo, Japan)
|
20
|
+
i: +9,
|
21
|
+
# J: Juliet Time: (Local Time Zone)
|
22
|
+
j: "",
|
23
|
+
# K: Kilo Time: UTC +10:00 (Sydney, Australia)
|
24
|
+
k: +10,
|
25
|
+
# L: Lima Time: UTC +11:00 (Honiara, Solomon Islands)
|
26
|
+
l: +11,
|
27
|
+
# M: Mike Time: UTC +12:00 (Wellington, New Zealand)
|
28
|
+
m: +12,
|
29
|
+
# N: November Time: UTC -01:00 (Azores)
|
30
|
+
n: -1,
|
31
|
+
# O: Oscar Time: UTC -02:00 (Gothab, Greenland)
|
32
|
+
o: -2,
|
33
|
+
# P: Papa Time: UTC -03:00 (Buenos Aires, Argentina)
|
34
|
+
p: -3,
|
35
|
+
# Q: Quebec Time: UTC -04:00 (Halifax, Nova Scotia)
|
36
|
+
q: -4,
|
37
|
+
# R: Romeo Time: UTC -05:00 (New York, NY United States)
|
38
|
+
r: -5,
|
39
|
+
# S: Sierra Time: UTC -06:00 (Dallas, TX United States)
|
40
|
+
s: -6,
|
41
|
+
# T: Tango Time: UTC -07:00 (Denver, CO United States)
|
42
|
+
t: -7,
|
43
|
+
# U: Uniform Time: UTC -08:00 (Los Angeles, CA United States)
|
44
|
+
u: -8,
|
45
|
+
# V: Victor Time: UTC -09:00 (Juneau, AK United States)
|
46
|
+
v: -9,
|
47
|
+
# W: Whiskey Time: UTC -10:00 (Honolulu, HI United States)
|
48
|
+
w: -10,
|
49
|
+
# X: X-Ray Time: UTC -11:00 (Nome, AK United States)
|
50
|
+
x: -11,
|
51
|
+
# Y: Yankee Time: UTC -12:00 (Suva, Fiji)
|
52
|
+
y: -12,
|
53
|
+
# Z: Zulu Time: UTC +-00:00 (Greenwich, England)
|
54
|
+
z: "UTC",
|
55
|
+
}
|
56
|
+
end
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SolarisFlare
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,14 +38,28 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: "A DTG is a DateTimeGroup which is used in the military to save time.
|
42
|
-
\ DTG\n are saved in the format DDHHMML MMM YY, where D is
|
56
|
+
\ DTG \n are saved in the format DDHHMML MMM YY, where D is
|
43
57
|
day, H is hour, L is \n letter, M is month, and Y is year.
|
44
|
-
\ The Month is the 3 character
|
45
|
-
for January, MAY for May, DEC for December and so on. Year
|
46
|
-
last two digits of the year e.g. 2019 is just 19. The
|
47
|
-
such as W for whiskey which is HST, Z for zulu which
|
48
|
-
used."
|
58
|
+
\ The Month is the 3 character \n representation such as JAN
|
59
|
+
for January, MAY for May, DEC for December and so \n on. Year
|
60
|
+
is only the last two digits of the year e.g. 2019 is just 19. The \n letter
|
61
|
+
is the zone code such as W for whiskey which is HST, Z for zulu which \n is
|
62
|
+
GMT, A-Z are the zones used."
|
49
63
|
email:
|
50
64
|
- shadowbomb20@gmail.com
|
51
65
|
executables: []
|
@@ -56,9 +70,12 @@ files:
|
|
56
70
|
- README.md
|
57
71
|
- Rakefile
|
58
72
|
- lib/dtg.rb
|
59
|
-
- lib/dtg/
|
73
|
+
- lib/dtg/core_datetime_ext.rb
|
74
|
+
- lib/dtg/core_time_ext.rb
|
75
|
+
- lib/dtg/core_timewithzone_ext.rb
|
60
76
|
- lib/dtg/railtie.rb
|
61
77
|
- lib/dtg/version.rb
|
78
|
+
- lib/dtg/zones.rb
|
62
79
|
- lib/tasks/dtg_tasks.rake
|
63
80
|
homepage: https://github.com/SolarisFlare/dtg/
|
64
81
|
licenses:
|
data/lib/dtg/core_ext.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
class Time
|
2
|
-
DTG_ZONES = {
|
3
|
-
# A: Alpha Time: UTC +01:00 (Paris, France)
|
4
|
-
a: +1,
|
5
|
-
# B: Bravo Time: UTC +02:00 (Athens, Greece)
|
6
|
-
b: +2,
|
7
|
-
# C: Charlie Time: UTC +03:00 (Moscow, Russia)
|
8
|
-
c: +3,
|
9
|
-
# D: Delta Time: UTC +04:00 (Kabul, Afghanistan)
|
10
|
-
d: +4,
|
11
|
-
# E: Echo Time: UTC +05:00 (New Delhi, India)
|
12
|
-
e: +5,
|
13
|
-
# F: Foxtrot Time: UTC +06:00 (Dhanka, Bangladesh)
|
14
|
-
f: +6,
|
15
|
-
# G: Golf Time: UTC +07:00 (Bangkok, Thailand)
|
16
|
-
g: +7,
|
17
|
-
# H: Hotel Time: UTC +08:00 (Beijing, China)
|
18
|
-
h: +8,
|
19
|
-
# I: India Time: UTC +09:00 (Tokyo, Japan)
|
20
|
-
i: +9,
|
21
|
-
# J: Juliet Time: (Local Time Zone)
|
22
|
-
j: '',
|
23
|
-
# K: Kilo Time: UTC +10:00 (Sydney, Australia)
|
24
|
-
k: +10,
|
25
|
-
# L: Lima Time: UTC +11:00 (Honiara, Solomon Islands)
|
26
|
-
l: +11,
|
27
|
-
# M: Mike Time: UTC +12:00 (Wellington, New Zealand)
|
28
|
-
m: +12,
|
29
|
-
# N: November Time: UTC -01:00 (Azores)
|
30
|
-
n: -1,
|
31
|
-
# O: Oscar Time: UTC -02:00 (Gothab, Greenland)
|
32
|
-
o: -2,
|
33
|
-
# P: Papa Time: UTC -03:00 (Buenos Aires, Argentina)
|
34
|
-
p: -3,
|
35
|
-
# Q: Quebec Time: UTC -04:00 (Halifax, Nova Scotia)
|
36
|
-
q: -4,
|
37
|
-
# R: Romeo Time: UTC -05:00 (New York, NY United States)
|
38
|
-
r: -5,
|
39
|
-
# S: Sierra Time: UTC -06:00 (Dallas, TX United States)
|
40
|
-
s: -6,
|
41
|
-
# T: Tango Time: UTC -07:00 (Denver, CO United States)
|
42
|
-
t: -7,
|
43
|
-
# U: Uniform Time: UTC -08:00 (Los Angeles, CA United States)
|
44
|
-
u: -8,
|
45
|
-
# V: Victor Time: UTC -09:00 (Juneau, AK United States)
|
46
|
-
v: -9,
|
47
|
-
# W: Whiskey Time: UTC -10:00 (Honolulu, HI United States)
|
48
|
-
w: -10,
|
49
|
-
# X: X-Ray Time: UTC -11:00 (Nome, AK United States)
|
50
|
-
x: -11,
|
51
|
-
# Y: Yankee Time: UTC -12:00 (Suva, Fiji)
|
52
|
-
y: -12,
|
53
|
-
# Z: Zulu Time: UTC +-00:00 (Greenwich, England)
|
54
|
-
z: 'UTC'
|
55
|
-
}
|
56
|
-
|
57
|
-
def to_dtg(zone = :z)
|
58
|
-
self.convert(zone).format(zone)
|
59
|
-
end
|
60
|
-
|
61
|
-
def format(zone = :z)
|
62
|
-
dtg = "%d%H%M#{zone.upcase} %b %y"
|
63
|
-
self.strftime(dtg)
|
64
|
-
end
|
65
|
-
|
66
|
-
def convert(zone = :z)
|
67
|
-
raise "Error: #{zone} is not a valid zone" unless DTG_ZONES.has_key?(zone.downcase)
|
68
|
-
(zone.downcase == :j) ? self : self.in_time_zone(DTG_ZONES[zone.downcase])
|
69
|
-
end
|
70
|
-
end
|