time-zone 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/lib/time/zone/locking.rb +7 -1
- data/lib/time/zone/timestamp.rb +9 -4
- data/lib/time/zone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e87828391a79bc472c63dabacbb85b98438e428c396506114e74188608710a82
|
4
|
+
data.tar.gz: aa45a0f8fc9ef29e3dafe0e4b090f1b999e0d0f98c071b147c9fa014eae4030b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c547d0b8324fa6120e152869a395b9658dbc07a5c5556886efc1ee7664b88af481ad7b086654b11d85d505ca8b55885c6638b0da21bc51d653e0410c561a31d
|
7
|
+
data.tar.gz: a1bad96bd14f8932432ef9349573b5e00badd6c075ba305ecb8451fba404fd5064273bfa5179d6d9c945a2000b4e2ced0b97fc192f5c0bab83487a041622b0c1
|
data/.travis.yml
CHANGED
data/lib/time/zone/locking.rb
CHANGED
@@ -30,12 +30,18 @@ class Time
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.zone
|
33
|
+
def self.zone
|
34
34
|
LOCK.synchronize do
|
35
35
|
ENV['TZ']
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
UTC = "UTC".freeze
|
40
|
+
|
41
|
+
def self.utc?
|
42
|
+
zone == UTC
|
43
|
+
end
|
44
|
+
|
39
45
|
def self.with(zone)
|
40
46
|
LOCK.synchronize do
|
41
47
|
original_zone = ENV['TZ']
|
data/lib/time/zone/timestamp.rb
CHANGED
@@ -38,7 +38,7 @@ class Time
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.from(time, zone)
|
41
|
-
self.new(time.year, time.month, time.day, time.hour, time.
|
41
|
+
self.new(time.year, time.month, time.day, time.hour, time.minute, time.second, zone)
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.parse(*args)
|
@@ -69,7 +69,11 @@ class Time
|
|
69
69
|
self.class.from(Time::Zone.convert(to_time, zone), zone)
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
# Generate a new time with the specified changes.
|
73
|
+
# @param months [Numeric] add this many months
|
74
|
+
# @param seconds [Numeric] add this many seconds
|
75
|
+
# @param zone [String] forcefully change the timezone without doing any conversion.
|
76
|
+
def with_offset(months = 0, seconds = 0, zone = @zone)
|
73
77
|
current = self
|
74
78
|
|
75
79
|
if months != 0
|
@@ -77,10 +81,11 @@ class Time
|
|
77
81
|
end
|
78
82
|
|
79
83
|
if seconds != 0
|
80
|
-
|
84
|
+
# https://bugs.ruby-lang.org/issues/14879
|
85
|
+
current = Time::Zone.convert(current.to_time + seconds, @zone)
|
81
86
|
end
|
82
87
|
|
83
|
-
self.class.from(current,
|
88
|
+
self.class.from(current, zone)
|
84
89
|
end
|
85
90
|
|
86
91
|
# Add duration in various units.
|
data/lib/time/zone/version.rb
CHANGED