Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: grammar of a singular amount ago #580

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,33 @@ function M.format_date(date_string)
elseif diff:spandays() > 0 and diff:spandays() > 30 and now:getyear() == d:getyear() then
return string.format("%s %d", d:fmt "%b", d:getday())
elseif diff:spandays() > 0 and diff:spandays() <= 30 then
return tostring(math.floor(diff:spandays())) .. " days ago"
local days = math.floor(diff:spandays())
if days == 1 then
return "1 day ago"
else
return tostring(days) .. " days ago"
end
elseif diff:spanhours() > 0 then
return tostring(math.floor(diff:spanhours())) .. " hours ago"
local hours = math.floor(diff:spanhours())
if hours == 1 then
return "1 hour ago"
else
return tostring(hours) .. " hours ago"
end
elseif diff:spanminutes() > 0 then
return tostring(math.floor(diff:spanminutes())) .. " minutes ago"
local minutes = math.floor(diff:spanminutes())
if minutes == 1 then
return "1 minute ago"
else
return tostring(minutes) .. " minutes ago"
end
elseif diff:spanseconds() > 0 then
return tostring(math.floor(diff:spanswconds())) .. " seconds ago"
local seconds = math.floor(diff:spanswconds())
if seconds == 1 then
return "1 second ago"
else
return tostring(seconds) .. " seconds ago"
end
else
return string.format("%s %s %d", d:getyear(), d:fmt "%b", d:getday())
end
Expand Down
Loading