From 61fb60508516b224ec78666187e70074397b37f8 Mon Sep 17 00:00:00 2001 From: champignoom <66909116+champignoom@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:46:25 +0800 Subject: [PATCH] fix(calendar): call `os.date` twice to generate correct weekday (#1058) fixes https://github.com/nvim-neorg/neorg/issues/1059 --- lua/neorg/modules/core/tempus/module.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/neorg/modules/core/tempus/module.lua b/lua/neorg/modules/core/tempus/module.lua index 15f94b0b4..4aaddb179 100644 --- a/lua/neorg/modules/core/tempus/module.lua +++ b/lua/neorg/modules/core/tempus/module.lua @@ -231,15 +231,14 @@ module.public = { ---@param parsed_date Date #The date to convert ---@return osdate #A Lua date to_lua_date = function(parsed_date) - return vim.tbl_deep_extend("force", os.date("*t"), { + return os.date("*t", os.time(vim.tbl_deep_extend("force", os.date("*t"), { day = parsed_date.day, month = parsed_date.month and parsed_date.month.number or nil, year = parsed_date.year, 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 lib.number_wrap(parsed_date.weekday.number + 1, 1, 7), - }) + }))) end, --- Converts a lua `osdate` to a Neorg date.