local_date_time_attributes 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979444c0483d8668e71c4443ff98f9431de32463af28b8a9009d1213442db259
|
4
|
+
data.tar.gz: 82f3b12c0b61d953794003c18db211a3806a0b42a0ca33f7dddb00d505602f03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44654e2a37cac9eace5e4acb56d311cf125571786cbc48f1da9778ebac958018eec7977ec008a9c56a14412802636de8d6e874e1959d1071b3512031b2f07d2b
|
7
|
+
data.tar.gz: 32d83fe883e0830947208a8a3befc91413eb589bb39bebfb0311490812e61649643aa42927737f65f00f12288958053f5302456e167c758f2c5b1835967a8e62
|
data/Gemfile.lock
CHANGED
@@ -11,14 +11,16 @@ module LocalDateTimeAttributes
|
|
11
11
|
# Returns a datetime in the timezone specified without changing the time
|
12
12
|
def to_local(time_zone = Time.zone.try(:name))
|
13
13
|
return if __getobj__.nil? || time_zone.nil?
|
14
|
-
ActiveSupport::TimeZone.new(time_zone).local_to_utc(__getobj__)
|
14
|
+
converted_timestamp = ActiveSupport::TimeZone.new(time_zone).local_to_utc(__getobj__)
|
15
|
+
converted_timestamp.in_time_zone(time_zone) if converted_timestamp.respond_to? :in_time_zone
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
20
|
def from_local(date_time)
|
20
21
|
return if date_time.nil?
|
21
|
-
ActiveSupport::TimeZone.new(active_record_timezone).local_to_utc(date_time)
|
22
|
+
converted_timestamp = ActiveSupport::TimeZone.new(active_record_timezone).local_to_utc(date_time)
|
23
|
+
converted_timestamp.in_time_zone(active_record_timezone) if converted_timestamp.respond_to? :in_time_zone
|
22
24
|
end
|
23
25
|
|
24
26
|
def active_record_timezone
|