dtg 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +39 -0
- data/.inch.yml +6 -0
- data/.prettierignore +49 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -42
- data/Gemfile.lock +70 -0
- data/LICENSE +21 -0
- data/README.md +225 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dtg.gemspec +46 -27
- data/dtg_zones.png +0 -0
- data/lib/dtg.rb +20 -7
- data/lib/dtg/active_support/time_with_zone_ext.rb +2 -2
- data/lib/dtg/date_time_ext.rb +3 -3
- data/lib/dtg/date_time_group.rb +54 -2
- data/lib/dtg/format.rb +59 -0
- data/lib/dtg/time_ext.rb +2 -2
- data/lib/dtg/version.rb +1 -1
- data/lib/dtg/zones.rb +2 -2
- data/spec/dtg/active_support/time_with_zone_ext_spec.rb +176 -0
- data/spec/dtg/date_time_ext_spec.rb +175 -0
- data/spec/dtg/date_time_group_spec.rb +73 -0
- data/spec/dtg/format_spec.rb +99 -0
- data/spec/dtg/time_ext_spec.rb +175 -0
- data/spec/{lib/dtg → dtg}/zones_spec.rb +29 -31
- data/spec/dtg_spec.rb +13 -0
- data/spec/spec_helper.rb +7 -94
- metadata +109 -18
- data/spec/lib/dtg/active_support/time_with_zone_ext_spec.rb +0 -169
- data/spec/lib/dtg/date_time_ext_spec.rb +0 -168
- data/spec/lib/dtg/date_time_group_spec.rb +0 -35
- data/spec/lib/dtg/time_ext_spec.rb +0 -168
- data/spec/lib/dtg_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b905a28bb6d4220efdfee37d3aa6a254f3bf4a22017010e588dffbdd16bdead
|
4
|
+
data.tar.gz: 99a344e5ae20681923d53be03995b265e99e49f926b04fe271e2d5bf04cba473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a8355c357bf52525c7364cd4f9bb3ed870364245b9944368778cf2b7b222ba16f989e6b51824e94f2c13f779ba0bc7c204f1768a2cb8233801d0c73ecd7498
|
7
|
+
data.tar.gz: f126562b3c2944657726f39d2fe214abb75a09993f6566859de69774d127f32a4ab259a03f49968fab3975442a0777a5eb8ecf0dddc5904bb124d701ac5aae3c
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# System Generated Files #
|
2
|
+
#########################
|
3
|
+
.DS_Store
|
4
|
+
.icloud
|
5
|
+
Desktop.ini
|
6
|
+
.git
|
7
|
+
.vscode
|
8
|
+
*.code-workspace
|
9
|
+
|
10
|
+
# Temporary Files and Directories #
|
11
|
+
###################################
|
12
|
+
temp.*
|
13
|
+
temp
|
14
|
+
TEMP.*
|
15
|
+
TEMP
|
16
|
+
TEMP/**/*
|
17
|
+
temp/**/*
|
18
|
+
|
19
|
+
# Gem Things #
|
20
|
+
##############
|
21
|
+
/.bundle/
|
22
|
+
/.yardoc
|
23
|
+
/_yardoc/
|
24
|
+
/coverage/
|
25
|
+
/doc/
|
26
|
+
/pkg/
|
27
|
+
/spec/reports/
|
28
|
+
/tmp/
|
29
|
+
*.gem
|
30
|
+
|
31
|
+
# RSpec #
|
32
|
+
#########
|
33
|
+
.rspec_status
|
34
|
+
|
35
|
+
|
36
|
+
# Custom #
|
37
|
+
#########
|
38
|
+
coverage/**/*
|
39
|
+
|
data/.inch.yml
ADDED
data/.prettierignore
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# System Files #
|
2
|
+
################
|
3
|
+
.DS_Store
|
4
|
+
.icloud
|
5
|
+
Desktop.ini
|
6
|
+
.git
|
7
|
+
.vscode
|
8
|
+
*.code-workspace
|
9
|
+
|
10
|
+
# Git Files #
|
11
|
+
#############
|
12
|
+
.git/**/*
|
13
|
+
.gitignore
|
14
|
+
CHANGELOG.md
|
15
|
+
CODE_OF_CONDUCT.md
|
16
|
+
LICENSE
|
17
|
+
README.md
|
18
|
+
dtg_zones.png
|
19
|
+
|
20
|
+
# Configuration Files #
|
21
|
+
#######################
|
22
|
+
.coveralls.yml
|
23
|
+
.inch.yml
|
24
|
+
.prettierignore
|
25
|
+
.rspec
|
26
|
+
.rspec_status
|
27
|
+
.ruby-version
|
28
|
+
.travis.yml
|
29
|
+
|
30
|
+
# Ruby Files #
|
31
|
+
##############
|
32
|
+
Gemfile
|
33
|
+
Gemfile.lock
|
34
|
+
bin/**/*
|
35
|
+
/.bundle/
|
36
|
+
/.yardoc
|
37
|
+
/_yardoc/
|
38
|
+
/coverage/
|
39
|
+
/doc/
|
40
|
+
/pkg/
|
41
|
+
/spec/reports/
|
42
|
+
/tmp/
|
43
|
+
*.gem
|
44
|
+
|
45
|
+
# Save my poor comments #
|
46
|
+
#########################
|
47
|
+
lib/dtg/zones.rb
|
48
|
+
lib/dtg/format.rb
|
49
|
+
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.5
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=e2777b300b5f2a88d223315832d34e3dd3e7ddaebb957c381105186be793540b
|
4
|
+
language: ruby
|
5
|
+
rvm:
|
6
|
+
- 2.5.5
|
7
|
+
deploy:
|
8
|
+
provider: rubygems
|
9
|
+
api_key:
|
10
|
+
secure: lt+CEA1/wbR6g2HxcUniU6bQAC3j14dhdyzI8xYPHQ6IosZTcxmrd/WMHFUXCt0aZFCNzk1LiG4bnxXKB+YAE43vdh5sb4s6gaOInd92ax8NPHjp86M7ctTkSgZN6e2tSR78hucC3scsXU3tXtzLCNI3eUOKHIlAMe1lsuZ8r7KRLUmvAJjVt8Nx+WMPj0qli9h1nywe1SKpJZqoLmu4TgRCWXHkzmyR6MEzFtkjVJgIZCrAFE2OdV7jb97wZHIRVfN4HOY4s78M/vrvXObNdiXUYB81TJLCxyV4nYm8BbJmKMprsFek3iw5VSrpJ66uOCsIB5XpRFC9xRBli09hTNCwNdBRw3lfMG1lFixH4E1PTK0aTjwJ0bqMCBsqVL6QisX8+Hwroft7Stdob+WGBiCLdkHbjLCUBqaw8AvaPnxBPW2soYboruzLhU1gwBpqoAuJlHsbdUGVVufHFFErp1Ev92U/MggvWNTJZ/+admnRTEgoHPmRcfpPc9dZw0FpI/nE8PwKULY6dg9ngAMXedtX0W63SIOAaTE9NPcp7/BWoMtBaD28Pgh7Y70O5vAUeh2aJYj6lQKvvaLM6OEhixOjQY7Py124lo6f50iznzHT5OK4Q4zKOqA3kly4m7Elr6faSGQ8xCEvTHLp20L5hMAwRQnmMHDWbe2FrAaG9Bk=
|
11
|
+
on:
|
12
|
+
tags: true
|
13
|
+
before_script:
|
14
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
15
|
+
- chmod +x ./cc-test-reporter
|
16
|
+
- ./cc-test-reporter before-build
|
17
|
+
script:
|
18
|
+
- bundle exec rspec
|
19
|
+
after_script:
|
20
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
File without changes
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -5,45 +5,3 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
# Bundler will treat runtime dependencies like base dependencies, and
|
6
6
|
# development dependencies will be added by default to the :development group.
|
7
7
|
gemspec
|
8
|
-
|
9
|
-
# Declare any dependencies that are still in development here instead of in
|
10
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
11
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
12
|
-
# your gem to rubygems.org.
|
13
|
-
|
14
|
-
# Used to test this gem for compatability and functionality
|
15
|
-
group :development, :test do
|
16
|
-
gem "cadre"
|
17
|
-
|
18
|
-
# Used for test suite reporting
|
19
|
-
gem 'coveralls', require: false
|
20
|
-
|
21
|
-
# Find places where code can be sped up
|
22
|
-
gem "fasterer"
|
23
|
-
|
24
|
-
# Code quality
|
25
|
-
gem "guard"
|
26
|
-
gem "guard-reek"
|
27
|
-
gem "guard-rspec"
|
28
|
-
gem "guard-rubocop"
|
29
|
-
|
30
|
-
# Check code quality extensions on git actions
|
31
|
-
gem "overcommit"
|
32
|
-
|
33
|
-
# Detect code smells for bad/strage code
|
34
|
-
gem "reek"
|
35
|
-
|
36
|
-
# RSpec for testing suite
|
37
|
-
gem "rspec"
|
38
|
-
gem "rspec-core"
|
39
|
-
gem "rspec-expectations"
|
40
|
-
gem "rspec-mocks"
|
41
|
-
gem "rspec-support"
|
42
|
-
|
43
|
-
# Code quality enforcer
|
44
|
-
gem "rubocop", "0.65.0"
|
45
|
-
gem "rubocop-rspec"
|
46
|
-
|
47
|
-
# StandardRB checks for consistent ruby conventions
|
48
|
-
gem "standard"
|
49
|
-
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dtg (5.0.0)
|
5
|
+
activesupport
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (6.0.0)
|
11
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
+
i18n (>= 0.7, < 2)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
16
|
+
concurrent-ruby (1.1.5)
|
17
|
+
coveralls (0.8.23)
|
18
|
+
json (>= 1.8, < 3)
|
19
|
+
simplecov (~> 0.16.1)
|
20
|
+
term-ansicolor (~> 1.3)
|
21
|
+
thor (>= 0.19.4, < 2.0)
|
22
|
+
tins (~> 1.6)
|
23
|
+
diff-lcs (1.3)
|
24
|
+
docile (1.3.2)
|
25
|
+
i18n (1.6.0)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
json (2.2.0)
|
28
|
+
minitest (5.12.2)
|
29
|
+
prettier (0.15.0)
|
30
|
+
rake (10.5.0)
|
31
|
+
rspec (3.8.0)
|
32
|
+
rspec-core (~> 3.8.0)
|
33
|
+
rspec-expectations (~> 3.8.0)
|
34
|
+
rspec-mocks (~> 3.8.0)
|
35
|
+
rspec-core (3.8.2)
|
36
|
+
rspec-support (~> 3.8.0)
|
37
|
+
rspec-expectations (3.8.5)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.8.0)
|
40
|
+
rspec-mocks (3.8.2)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.8.0)
|
43
|
+
rspec-support (3.8.3)
|
44
|
+
simplecov (0.16.1)
|
45
|
+
docile (~> 1.1)
|
46
|
+
json (>= 1.8, < 3)
|
47
|
+
simplecov-html (~> 0.10.0)
|
48
|
+
simplecov-html (0.10.2)
|
49
|
+
term-ansicolor (1.7.1)
|
50
|
+
tins (~> 1.0)
|
51
|
+
thor (0.20.3)
|
52
|
+
thread_safe (0.3.6)
|
53
|
+
tins (1.21.1)
|
54
|
+
tzinfo (1.2.5)
|
55
|
+
thread_safe (~> 0.1)
|
56
|
+
zeitwerk (2.1.10)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bundler (~> 1.17)
|
63
|
+
coveralls
|
64
|
+
dtg!
|
65
|
+
prettier
|
66
|
+
rake (~> 10.0)
|
67
|
+
rspec (~> 3.0)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.17.3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Sean Harding
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/SolarisFlare/dtg.svg?branch=master)](https://travis-ci.org/SolarisFlare/dtg)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/github/SolarisFlare/dtg/badge.svg?branch=master)](https://coveralls.io/github/SolarisFlare/dtg?branch=master)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/c0d2545fedb195f5d647/maintainability)](https://codeclimate.com/github/SolarisFlare/dtg/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/c0d2545fedb195f5d647/test_coverage)](https://codeclimate.com/github/SolarisFlare/dtg/test_coverage)
|
5
|
+
[![Inline docs](http://inch-ci.org/github/SolarisFlare/dtg.svg?branch=master)](http://inch-ci.org/github/SolarisFlare/dtg)
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/dtg.svg)](https://badge.fury.io/rb/dtg)
|
8
|
+
[![Downloads](https://img.shields.io/gem/dt/dtg.svg)](https://rubygems.org/gems/dtg)
|
9
|
+
[![Download Rank](https://img.shields.io/gem/rt/dtg.svg)](https://rubygems.org/gems/dtg)
|
10
|
+
[![Daily Download Rank](https://img.shields.io/gem/rd/dtg.svg)](https://rubygems.org/dtg)
|
11
|
+
[![Yard Documentation](https://img.shields.io/badge/YARD%20Documentation-Auto-blue.svg)](https://rubydoc.info/github/SolarisFlare/dtg/)
|
12
|
+
|
13
|
+
[![License](https://img.shields.io/github/license/SolarisFlare/dtg.svg)](https://raw.githubusercontent.com/SolarisFlare/dtg/master/LICENSE)
|
14
|
+
[![GitHub version](https://badge.fury.io/gh/SolarisFlare%2Fdtg.svg)](https://badge.fury.io/gh/SolarisFlare%2Fdtg)
|
15
|
+
[![Open Github Issues](https://img.shields.io/github/issues-raw/SolarisFlare/dtg.svg)](https://github.com/SolarisFlare/dtg/issues)
|
16
|
+
[![Closed Github Issues](https://img.shields.io/github/issues-closed-raw/SolarisFlare/dtg.svg)](https://github.com/SolarisFlare/dtg/issues)
|
17
|
+
|
18
|
+
![Star Project](https://img.shields.io/github/stars/SolarisFlare/dtg.svg?style=social)
|
19
|
+
![Watch Project](https://img.shields.io/github/watchers/SolarisFlare/dtg.svg?style=social)
|
20
|
+
![Follow Me](https://img.shields.io/github/followers/SolarisFlare.svg?style=social)
|
21
|
+
|
22
|
+
# Dtg
|
23
|
+
|
24
|
+
DTG is a ruby gem to convert Time objects into DTG format.
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
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.
|
29
|
+
|
30
|
+
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.
|
31
|
+
|
32
|
+
## Table of Contents
|
33
|
+
|
34
|
+
1. [DTG](#dtg)
|
35
|
+
2. [Table of Contents](#table-of-contents)
|
36
|
+
3. [Usage](#usage)
|
37
|
+
1. [DTG Zones](#dtg-zones)
|
38
|
+
2. [DTG Zone Map](#dtg-zone-map)
|
39
|
+
4. [Installation](#installation)
|
40
|
+
5. [Testing](#testing)
|
41
|
+
6. [Compatability](#compatability)
|
42
|
+
7. [Problems](#problems)
|
43
|
+
8. [Contributing](#contributing)
|
44
|
+
9. [License](#license)
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
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).
|
49
|
+
|
50
|
+
To use:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
TIMEOBJECT.to_dtg
|
54
|
+
```
|
55
|
+
|
56
|
+
and it will return the time object as a string in the zulu timezone in dtg format.
|
57
|
+
|
58
|
+
For other DTG formats:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
TIMEOBJECT.to_dtg(:zone)
|
62
|
+
```
|
63
|
+
|
64
|
+
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.
|
65
|
+
|
66
|
+
*__USAGE NOTES__: Ensure that in your application or before using this gems methods(convert/to_dtg) which calls the in_time_zone method, you must set Time.zone = "yourtimezone(HST for me)". Otherwise in_time_zone will be called and return nil:NilObject due to Time.zone returning nil(ActiveSupport thing). Rails has a place in the application configuration to set the Time.zone before startup.*
|
67
|
+
|
68
|
+
### DTG Zones
|
69
|
+
|
70
|
+
- A: Alpha Time: UTC +01:00 (Paris, France)
|
71
|
+
- B: Bravo Time: UTC +02:00 (Athens, Greece)
|
72
|
+
- C: Charlie Time: UTC +03:00 (Moscow, Russia)
|
73
|
+
- D: Delta Time: UTC +04:00 (Kabul, Afghanistan)
|
74
|
+
- E: Echo Time: UTC +05:00 (New Delhi, India)
|
75
|
+
- F: Foxtrot Time: UTC +06:00 (Dhanka, Bangladesh)
|
76
|
+
- G: Golf Time: UTC +07:00 (Bangkok, Thailand)
|
77
|
+
- H: Hotel Time: UTC +08:00 (Beijing, China)
|
78
|
+
- I: India Time: UTC +09:00 (Tokyo, Japan)
|
79
|
+
- J: Juliet Time: (Local Time Zone)
|
80
|
+
- K: Kilo Time: UTC +10:00 (Sydney, Australia)
|
81
|
+
- L: Lima Time: UTC +11:00 (Honiara, Solomon Islands)
|
82
|
+
- M: Mike Time: UTC +12:00 (Wellington, New Zealand)
|
83
|
+
- N: November Time: UTC -01:00 (Azores)
|
84
|
+
- O: Oscar Time: UTC -02:00 (Gothab, Greenland)
|
85
|
+
- P: Papa Time: UTC -03:00 (Buenos Aires, Argentina)
|
86
|
+
- Q: Quebec Time: UTC -04:00 (Halifax, Nova Scotia)
|
87
|
+
- R: Romeo Time: UTC -05:00 (New York, NY United States)
|
88
|
+
- S: Sierra Time: UTC -06:00 (Dallas, TX United States)
|
89
|
+
- T: Tango Time: UTC -07:00 (Denver, CO United States)
|
90
|
+
- U: Uniform Time: UTC -08:00 (Los Angeles, CA United States)
|
91
|
+
- V: Victor Time: UTC -09:00 (Juneau, AK United States)
|
92
|
+
- W: Whiskey Time: UTC -10:00 (Honolulu, HI United States)
|
93
|
+
- X: X-Ray Time: UTC -11:00 (Nome, AK United States)
|
94
|
+
- Y: Yankee Time: UTC -12:00 (Suva, Fiji)
|
95
|
+
- Z: Zulu Time: UTC +-00:00 (Greenwich, England)
|
96
|
+
|
97
|
+
### DTG Zone Map
|
98
|
+
|
99
|
+
![DTG zones displayed across the map with their offsets](dtg_zones.png?raw=true "DTG Zones")
|
100
|
+
|
101
|
+
## Installation
|
102
|
+
|
103
|
+
Add this line to your application's Gemfile:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
gem 'dtg'
|
107
|
+
```
|
108
|
+
|
109
|
+
And then execute:
|
110
|
+
```bash
|
111
|
+
bundle install
|
112
|
+
```
|
113
|
+
|
114
|
+
Or install it yourself as:
|
115
|
+
```bash
|
116
|
+
cd dtg
|
117
|
+
gem build dtg
|
118
|
+
gem install dtg
|
119
|
+
```
|
120
|
+
|
121
|
+
## Testing
|
122
|
+
|
123
|
+
If you would like to test this gem before adding it to your project to see it's functionality, follow these steps:
|
124
|
+
|
125
|
+
1. Clone the repository
|
126
|
+
|
127
|
+
```sh
|
128
|
+
git clone https://github.com/SolarisFlare/dtg
|
129
|
+
```
|
130
|
+
|
131
|
+
2. cd into the project
|
132
|
+
|
133
|
+
3. Build the gem
|
134
|
+
|
135
|
+
```sh
|
136
|
+
gem build dtg
|
137
|
+
```
|
138
|
+
|
139
|
+
4. Install the gem
|
140
|
+
|
141
|
+
```sh
|
142
|
+
gem install dtg
|
143
|
+
```
|
144
|
+
|
145
|
+
5. Start the ruby console
|
146
|
+
|
147
|
+
```sh
|
148
|
+
irb
|
149
|
+
```
|
150
|
+
|
151
|
+
OR
|
152
|
+
|
153
|
+
the ruby running console of your choice (pry, rails console / rails c, ...)
|
154
|
+
|
155
|
+
6. Require it to load it into the console (only necessary for irb, others like rails should usually load automatically but it doesn't hurt if it doesn't work!)
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
require 'dtg'
|
159
|
+
```
|
160
|
+
|
161
|
+
7. Test away
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
#<Tested in irb console and rails console, also works in Pry console>
|
165
|
+
|
166
|
+
y = Time.zone.now
|
167
|
+
y.dtg
|
168
|
+
y = Time.zone.now.to_dtg(:j)
|
169
|
+
y
|
170
|
+
|
171
|
+
x = Time.now
|
172
|
+
x.dtg
|
173
|
+
x.to_dtg(:j)
|
174
|
+
x.to_dtg(:J)
|
175
|
+
x.to_dtg
|
176
|
+
x.to_dtg(:z)
|
177
|
+
x.to_dtg(:Z)
|
178
|
+
x.to_dtg(:W)
|
179
|
+
DateTimeGroup.from_dtg(x.to_dtg(:m))
|
180
|
+
|
181
|
+
z = DateTime.now
|
182
|
+
z.dtg
|
183
|
+
DateTimeGroup.convert(z.to_dtg, :w)
|
184
|
+
z.to_dtg :w
|
185
|
+
z.convert :w
|
186
|
+
z.to_dtg :c
|
187
|
+
DateTimeGroup.parse z
|
188
|
+
|
189
|
+
Time.now.to_dtg(:a)
|
190
|
+
DateTime.now.to_dtg :Q
|
191
|
+
Time.zone.now.to_dtg L.to_sym
|
192
|
+
```
|
193
|
+
|
194
|
+
> 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.
|
195
|
+
|
196
|
+
## Compatability
|
197
|
+
|
198
|
+
~~All versions of DTG are 100% compatible with all versions of rails so long as date(DateTime) time(Time) and TimeWithZone(ActiveSupport::TimeWithZone) are present otherwise the features associated with those classes will not be available. The gem will still function without them as I have discovered through and the features associated with the missing classes will just not be there, however, attempting to use the features with one of the non-existant classes it integrates into will most likely error or cause strange behaviours so I recommend only using with the classes your application contains(i.e. do not attempt to use ActiveSupport::TimeWithZone with pure ruby unless you include it somehow in your application), luckily, all rails applications contain all 3 classes and any ruby application contains Time by default and as of lately, also contains date(I think) although the TimeWithZone will most likely not be there since it is from activesupport which is part of the rails gem.~~
|
199
|
+
|
200
|
+
**This Gem now includes the necessary libraries from active_support and date to work without rails. It is 100% compatible with all versions of rails/active_support. If you do not set Time.zone to a valid zone(many ways to do this, I recommend the 3 char code such as HST for Hawaiian Standard Time when you set your timezone to ensure proper zone coverage if your zone does daylight savings time or summer time. DateTimeGroup#convert and DateTimeGroup#to_dtg(which calls convert) will result in nil:NilObject if Time.zone is not set before using them. Works with irb/pry/ruby/rails and probably more that I haven't tested yet. Enjoy!**
|
201
|
+
|
202
|
+
## Problems
|
203
|
+
|
204
|
+
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 otherwise it will convert all time objects from UTC +00:00 which is the rails default zone (Etc/UTC) and therefore can provide unintended results. TimeWithZone is different and therefore 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. You also cannot truly convert from J (Juliet or local time) to any other dtg zone. This is because DTG store their zone as an offset letter code, whereas the code J is the local time (but what is local?) and the only way to know the local time would be to take it from the time of the machine doing the conversion! However, what if I emailed you something in J, there would be no way to tell what its time code actually is because you could insert it into a database and would then not know what "local" is for it. Luckily, people only use J rarely or in small circumstances. Almost everything sent is first changed to Z and everyone knows what their local time is in Z and convert it for internal documents. If you read old historical documents that use the dtg zone codes, you can see this. I included a parse method so you can imlpement your own parsers/formatters from a dtg in case you run into J codes (hopefully never).
|
205
|
+
|
206
|
+
## Development
|
207
|
+
|
208
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
209
|
+
|
210
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
211
|
+
|
212
|
+
## Contributing
|
213
|
+
|
214
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dtg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
215
|
+
|
216
|
+
If you want to contribute please let me know though either an email or you can just submit a pull request to add anything or open an issue and I can look through it with you!
|
217
|
+
|
218
|
+
## License
|
219
|
+
|
220
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
221
|
+
|
222
|
+
## Code of Conduct
|
223
|
+
|
224
|
+
Everyone interacting in the Dtg project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SolarisFlare/dtg/blob/master/CODE_OF_CONDUCT.md).
|
225
|
+
|