Skip to content

Commit

Permalink
fix(tempus): properly handle conversions w.r.t Sun-Sat/Mon-Sun
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed May 17, 2023
1 parent 0525928 commit e39fa1b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/neorg/modules/core/tempus/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ module.public = {
hour = parsed_date.time and parsed_date.time.hour,
min = parsed_date.time and parsed_date.time.minute,
sec = parsed_date.time and parsed_date.time.second,
wday = parsed_date.weekday and parsed_date.weekday.number,
wday = parsed_date.weekday and neorg.lib.number_wrap(parsed_date.weekday.number + 1, 1, 7),
isdst = true,
}
end,
Expand All @@ -256,12 +256,14 @@ module.public = {
table.insert(months, os.date("%B", os.time({ year = 2000, month = i, day = 1 })):lower())
end

-- os.date("*t") returns wday with Sunday as 1, needs to be
-- converted to Monday as 1
local converted_weekday = neorg.lib.number_wrap(osdate.wday - 1, 1, 7)

return module.private.tostringable_date({
-- os.date("*t") returns wday with Sunday as 1, needs to be
-- converted to Monday as 1
weekday = osdate.wday and {
number = osdate.wday == 1 and 7 or osdate.wday-1,
name = neorg.lib.title(weekdays[osdate.wday == 1 and 7 or osdate.wday-1]),
number = converted_weekday,
name = neorg.lib.title(weekdays[converted_weekday]),
} or nil,
day = osdate.day,
month = osdate.month and {
Expand Down

0 comments on commit e39fa1b

Please sign in to comment.