dtg 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d41d3d30878513e54ace3d7449ba59abad4f24cc4c675f051fb50dfb17be92b9
4
- data.tar.gz: c4c0f569d96219b6547310def9e4f3bc430a9628204467d7dbecc7e555aaa2c9
3
+ metadata.gz: 9f366bb0470f56abd6358a4b0c01545401fa370fb57b12877187f1b30e34ce2f
4
+ data.tar.gz: 76df55ea4b078f16e2b1dbb608af0ab14b93dab9f2a2a3be1f76e66ff6dc37e6
5
5
  SHA512:
6
- metadata.gz: eaf842f9354b842328f0d7c6566969a1be7c100219045dad016ce71b22fdb3c6acc3e21e6db7c079d8d6f321381b5b0647edb80222a5579d30544e1efd9c3351
7
- data.tar.gz: 1e8f778551ed82d62b6a8be5d8d7dda7e4d53aa057c5703c61e8cabf57cf05fbe8cf7290ec49f92393e35dabf8611291b03b5c4900c76ca23c0953455fb6c3d6
6
+ metadata.gz: 87232c8fc667bccc35f53ef04be862ab8cb8ccb6d092812d089f58fe37acc50764c3054dbd278f9cdb5ec89219220726bf893a374aba32cd17e0960aab11445a
7
+ data.tar.gz: fd2f67556bf33150968bcb2a06078e2488cc93cf840db5e545491d8e376960f9d53db8dc5b8a0d3f48c6d6b8eec3fc87a879860cd3f3e85f05e7a2126e54e750
data/README.md CHANGED
@@ -1,6 +1,23 @@
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)
3
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)
4
21
 
5
22
  # Dtg
6
23
 
@@ -155,10 +172,7 @@ Time.zone.now.to_dtg L.to_sym
155
172
 
156
173
  ## Problems
157
174
 
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
-
175
+ 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.
162
176
 
163
177
  ## Contributing
164
178
 
data/lib/dtg.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require "dtg/railtie"
2
2
  require "dtg/zones"
3
- require "dtg/core_datetime_ext"
4
- require "dtg/core_time_ext"
5
- require "dtg/core_timewithzone_ext"
3
+ require "dtg/date_time_ext"
4
+ require "dtg/time_ext"
5
+ require "dtg/active_support/time_with_zone_ext"
6
6
 
7
7
  module Dtg
8
8
  def dtg
@@ -1,5 +1,5 @@
1
1
  require 'dtg'
2
- require_relative 'zones'
2
+ require_relative '../zones'
3
3
 
4
4
  class ActiveSupport::TimeWithZone
5
5
  include Dtg
@@ -10,13 +10,15 @@ class ActiveSupport::TimeWithZone
10
10
  end
11
11
 
12
12
  def format(zone = :z)
13
- dtg = "%d%H%M#{zone.upcase} %b %y"
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"
14
16
  strftime(dtg)
15
17
  end
16
18
 
17
19
  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])
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])
21
23
  end
22
24
  end
@@ -10,13 +10,15 @@ class DateTime
10
10
  end
11
11
 
12
12
  def format(zone = :z)
13
- dtg = "%d%H%M#{zone.upcase} %b %y"
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"
14
16
  strftime(dtg)
15
17
  end
16
18
 
17
19
  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])
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])
21
23
  end
22
24
  end
@@ -10,13 +10,15 @@ class Time
10
10
  end
11
11
 
12
12
  def format(zone = :z)
13
- dtg = "%d%H%M#{zone.upcase} %b %y"
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"
14
16
  strftime(dtg)
15
17
  end
16
18
 
17
19
  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])
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])
21
23
  end
22
24
  end
@@ -1,3 +1,3 @@
1
1
  module Dtg
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  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: 2.0.0
4
+ version: 3.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-07-18 00:00:00.000000000 Z
11
+ date: 2019-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,10 +70,10 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - lib/dtg.rb
73
- - lib/dtg/core_datetime_ext.rb
74
- - lib/dtg/core_time_ext.rb
75
- - lib/dtg/core_timewithzone_ext.rb
73
+ - lib/dtg/active_support/time_with_zone_ext.rb
74
+ - lib/dtg/date_time_ext.rb
76
75
  - lib/dtg/railtie.rb
76
+ - lib/dtg/time_ext.rb
77
77
  - lib/dtg/version.rb
78
78
  - lib/dtg/zones.rb
79
79
  - lib/tasks/dtg_tasks.rake