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
def merge_timestamp
timestamp = raw.dig('commit', 'committerTimestamp')
Time.at(timestamp / 1000.0) if timestamp.is_a?(Integer)
self.class.convert_timestamp(timestamp)
end
def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer)
self.class.convert_timestamp(created_date)
end
private
......
......@@ -12,6 +12,10 @@ module BitbucketServer
def self.decorate(entries)
entries.map { |entry| new(entry)}
end
def self.convert_timestamp(time_usec)
Time.at(time_usec / 1000) if time_usec.is_a?(Integer)
end
end
end
end
......@@ -40,11 +40,11 @@ module BitbucketServer
end
def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer)
self.class.convert_timestamp(created_date)
end
def updated_at
Time.at(updated_date / 1000) if updated_date.is_a?(Integer)
self.class.convert_timestamp(created_date)
end
# Bitbucket Server supports the ability to reply to any comment
......
......@@ -34,11 +34,11 @@ module BitbucketServer
end
def created_at
Time.at(created_date / 1000) if created_date.is_a?(Integer)
self.class.convert_timestamp(created_date)
end
def updated_at
Time.at(updated_date / 1000) if created_date.is_a?(Integer)
self.class.convert_timestamp(updated_date)
end
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