ADD format time method
This commit is contained in:
parent
cfb794c94f
commit
58d8c911a8
|
@ -62,4 +62,14 @@ module RepositoriesHelper
|
||||||
|
|
||||||
return content
|
return content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# unix_time values for example: 1604382982
|
||||||
|
def render_format_time_with_unix(unix_time)
|
||||||
|
Time.at(unix_time).strftime("%Y-%m-%d %H:%M")
|
||||||
|
end
|
||||||
|
|
||||||
|
# date for example: 2020-11-01T19:57:27+08:00
|
||||||
|
def render_format_time_with_date(date)
|
||||||
|
date.to_time.strftime("%Y-%m-%d %H:%M")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,5 +9,6 @@ json.committer do
|
||||||
end
|
end
|
||||||
json.timestamp render_unix_time(commit['Committer']['When'])
|
json.timestamp render_unix_time(commit['Committer']['When'])
|
||||||
json.time_from_now time_from_now(commit['Committer']['When'])
|
json.time_from_now time_from_now(commit['Committer']['When'])
|
||||||
|
json.created_at render_format_time_with_date(commit['Committer']['When'])
|
||||||
json.message commit['CommitMessage']
|
json.message commit['CommitMessage']
|
||||||
json.sha commit['Sha']
|
json.sha commit['Sha']
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
created_at = Time.at(entry['latest_commit']['created_at'].to_i).strftime("%Y-%m-%d %H:%M")
|
|
||||||
json.commit do
|
json.commit do
|
||||||
json.message entry['latest_commit']['message']
|
json.message entry['latest_commit']['message']
|
||||||
json.sha entry['latest_commit']['sha']
|
json.sha entry['latest_commit']['sha']
|
||||||
json.created_at created_at
|
json.created_at render_format_time_with_unix(entry['latest_commit']['created_at'].to_i)
|
||||||
json.time_from_now time_from_now(created_at)
|
json.time_from_now time_from_now(created_at)
|
||||||
json.created_at_unix entry['latest_commit']['created_at']
|
json.created_at_unix entry['latest_commit']['created_at']
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue