Skip to content

Conversation

@Bapham12
Copy link
Member

Add DateI18n module for processing date strings.

Add DateI18n module for processing date strings.
Comment on lines +281 to +285
local monthMsg = MonthCase(month, case, lang)
if monthMsg and monthMsg ~= '' then -- make sure it exists
dFormat = strReplace(dFormat, 'F', '"'..monthMsg..'"') -- replace default month with month name we already looked up
dFormat = strReplace(dFormat, 'xg', '"'..monthMsg..'"')
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crash when month is nil. If datecode is 'Y' (year only), month will be nil (from line 252: datenum[2]). However, if a case parameter is provided (line 277 check passes), the code calls MonthCase(month, case, lang) at line 281 with nil month. This causes T[month][case] at line 217 to attempt indexing T[nil], resulting in a crash.

-- Add nil check for month
if month and (case ~= '') then
    local monthMsg = MonthCase(month, case, lang)
    if monthMsg and monthMsg ~= '' then
        dFormat = strReplace(dFormat, 'F',  '"'..monthMsg..'"')
        dFormat = strReplace(dFormat, 'xg', '"'..monthMsg..'"')
    end
end
Suggested change
local monthMsg = MonthCase(month, case, lang)
if monthMsg and monthMsg ~= '' then -- make sure it exists
dFormat = strReplace(dFormat, 'F', '"'..monthMsg..'"') -- replace default month with month name we already looked up
dFormat = strReplace(dFormat, 'xg', '"'..monthMsg..'"')
end
if month and (case ~= '') then
local monthMsg = MonthCase(month, case, lang)
if monthMsg and monthMsg ~= '' then -- make sure it exists
dFormat = strReplace(dFormat, 'F', '"'..monthMsg..'"') -- replace default month with month name we already looked up
dFormat = strReplace(dFormat, 'xg', '"'..monthMsg..'"')
end
end

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

This comment came from an experimental review—please leave feedback if it was helpful/unhelpful. Learn more about experimental comments here.

@Bapham12 Bapham12 merged commit 12773c3 into main Jan 13, 2026
3 checks passed
@Bapham12 Bapham12 deleted the Bapham12-patch-2 branch January 13, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants