Skip to content

Commit 5985d12

Browse files
committed
allow negative timestamps on content import
closes #4551 Change-Id: I39772343d2a33cd6a0c6e08457d32ce871c9932c Reviewed-on: https://gerrit.instructure.com/3598 Reviewed-by: Brian Palmer <brianp@instructure.com> Reviewed-by: Zach Wily <zach@instructure.com> Tested-by: Hudson <hudson@instructure.com>
1 parent 4c9f027 commit 5985d12

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/canvas_migration/migrator_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ module Canvas::MigratorHelper
3232
def self.get_utc_time_from_timestamp(timestamp)
3333
# timestamp can be either a time string in the format "2011-04-30T00:00:00-06:00",
3434
# or an integer epoch * 1000
35-
if timestamp.to_s.match(/[^0-9.]/)
36-
Time.parse(timestamp.to_s)
37-
else
35+
if timestamp.to_s.match(/^-?[0-9.]+$/)
3836
timestamp = timestamp.to_i/ 1000 rescue 0
3937
t = nil
4038
if timestamp > 0
4139
t = Time.at(timestamp)
4240
t = Time.utc(t.year, t.month, t.day, t.hour, t.min, t.sec)
4341
end
4442
t
43+
else
44+
Time.parse(timestamp.to_s)
4545
end
4646
end
4747

0 commit comments

Comments
 (0)