Skip to content

Commit

Permalink
fix(tempus): supply unprovided parameters from the current date when …
Browse files Browse the repository at this point in the history
…converting to `osdate` (supercedes #897)
  • Loading branch information
vhyrro committed May 25, 2023
1 parent dd3e8dc commit f367451
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/neorg/modules/core/esupports/hop/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ module.public = {
end

calendar.select_date({
date = vim.tbl_deep_extend("force", os.date("*t"), tempus.to_lua_date(parsed_date)),
date = tempus.to_lua_date(parsed_date),
callback = function(input)
local start_row, start_col, end_row, end_col = parsed_link_information.link_node:range()
vim.api.nvim_buf_set_text(
Expand Down
5 changes: 2 additions & 3 deletions lua/neorg/modules/core/tempus/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,15 @@ module.public = {
---@param parsed_date Date #The date to convert
---@return osdate #A Lua date
to_lua_date = function(parsed_date)
return {
return 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 neorg.lib.number_wrap(parsed_date.weekday.number + 1, 1, 7),
isdst = true,
}
})
end,

--- Converts a lua `osdate` to a Neorg date.
Expand Down

0 comments on commit f367451

Please sign in to comment.