Skip to content

core.tempus.parse_date errors on any unambiguous month or weekday name #1830

Description

@r35krag0th

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

NVIM v0.12.2, release build, LuaJIT 2.1.1774638290

Neorg setup

require("neorg").setup({
  load = {
    ["core.defaults"] = {},
    ["core.dirman"] = {
      config = { workspaces = { test = "/tmp/norg-repro" }, default_workspace = "test" },
    },
    ["core.journal"] = { config = { workspace = "test" } },
  },
})

Reproduced on 9.6.4 and against current main. core/tempus/module.lua is byte identical between the two, and the setup doesn't really matter — anything that loads core.tempus will do it.

Actual behavior

E5113: ...core/tempus/module.lua:355: bad argument #1 to 'unpack' (table expected, got nil)

parse_date builds valid_months keyed by month name and then reads it positionally, so the single-match branch always hands unpack a nil.

https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/tempus/module.lua#L346
https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/tempus/module.lua#L355

valid_months[month] = i                                               -- 346
...
local valid_month_name, valid_month_number = unpack(valid_months[1])  -- 355

valid_months[1] is nil unless a month is literally named "1". valid_weekdays is the same shape at 374/383.

Any unambiguous month or weekday word triggers it: August, Aug, aug, Friday, Fri, 21 August 2026, Aug 21 2026. Ambiguous prefixes are fine, since count > 1 returns before reaching the unpack — so Ju gives you the ambiguity message and June errors. Only the inputs that should work fail.

One consequence is that parse_date can't read back what to_date writes:

local tempus = require("neorg.core").modules.get_module("core.tempus")
tostring(tempus.to_date(os.date("*t")))     -- "Friday 21 August 2026"
tempus.parse_date("Friday 21 August 2026")  -- errors

Expected behavior

parse_date("21 Aug 2026") returns a parsed date table, and round trips with to_date.

Steps to reproduce

:lua require("neorg.core").modules.get_module("core.tempus").parse_date("21 Aug 2026")

Other information

count > 1 uses vim.tbl_keys(valid_months), so the name-keyed map looks deliberate and I think the read site is the thing that's wrong:

local valid_month_name, valid_month_number = next(valid_months)

As far as I can tell the count == 1 path has never worked, which fits b73ec2f being the only commit that has touched these lines. It's reachable from the calendar's typed date entry (core/ui/calendar/views/monthly/module.lua:1131) and from date links in core/esupports/hop/module.lua:627. Clicking a date in the calendar goes through to_date instead and works fine, which is probably why this hasn't come up before.

Help

Yes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions