Commit dd937377 authored by Stan Hu's avatar Stan Hu

Use a class method to consolidate timestamp conversion

parent ae6b48d2
...@@ -38,11 +38,11 @@ module BitbucketServer ...@@ -38,11 +38,11 @@ module BitbucketServer
def merge_timestamp def merge_timestamp
timestamp = raw.dig('commit', 'committerTimestamp') timestamp = raw.dig('commit', 'committerTimestamp')
Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer) self.class.convert_timestamp(timestamp)
end end
def created_at def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer) self.class.convert_timestamp(created_date)
end end
private private
......
...@@ -12,6 +12,10 @@ module BitbucketServer ...@@ -12,6 +12,10 @@ module BitbucketServer
def self.decorate(entries) def self.decorate(entries)
entries.map { |entry| new(entry)} entries.map { |entry| new(entry)}
end end
def self.convert_timestamp(time_usec)
Time.at(time_usec / 1000) if time_usec.is_a?(Integer)
end
end end
end end
end end
...@@ -40,11 +40,11 @@ module BitbucketServer ...@@ -40,11 +40,11 @@ module BitbucketServer
end end
def created_at def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer) self.class.convert_timestamp(created_date)
end end
def updated_at def updated_at
Time.at(updated_date / 1000) if updated_date.is_a?(Integer) self.class.convert_timestamp(created_date)
end end
# Bitbucket Server supports the ability to reply to any comment # Bitbucket Server supports the ability to reply to any comment
......
...@@ -34,11 +34,11 @@ module BitbucketServer ...@@ -34,11 +34,11 @@ module BitbucketServer
end end
def created_at def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer) self.class.convert_timestamp(created_date)
end end
def updated_at def updated_at
Time.at(updated_date / 1000) if created_date.is_a?(Integer) self.class.convert_timestamp(updated_date)
end end
def title def title
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment