Skip to content

Commit 8f0c1cc

Browse files
KevinSchiffmannPaxa
authored andcommitted
Get utc_offset from current value if possible
1 parent 5c1dfd6 commit 8f0c1cc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/fast_excel.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ def self.lxw_time(time)
9191
# https://support.microsoft.com/en-us/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel
9292
def self.date_num(time, offset = nil)
9393
unless offset
94-
# Try use Rails' app timezone
95-
if Time.respond_to?(:zone)
94+
# Try use value utc_offset
95+
if time.respond_to?(:utc_offset)
96+
offset = time.utc_offset
97+
# Else try use Rails' app timezone
98+
elsif Time.respond_to?(:zone)
9699
offset = Time.zone.utc_offset
97100
else
98101
offset = 0 # rollback to UTC

0 commit comments

Comments
 (0)