diff --git a/spec/date_ext_spec.lua b/spec/date_ext_spec.lua index d44ee6aed09..773638454f8 100644 --- a/spec/date_ext_spec.lua +++ b/spec/date_ext_spec.lua @@ -20,8 +20,17 @@ describe('Date', function() DateExt.readTimestamp('2021-10-17 17:40 EDT') assert.stub(FormatDateSpy).was.called_with(mw.language, 'U', '20211017 17:40 -4:00') + DateExt.readTimestamp('2021-10-17 - 17:40 EDT') + assert.stub(FormatDateSpy).was.called_with(mw.language, 'U', '20211017 17:40 -4:00') + DateExt.readTimestamp('2021-10-17 21:40') assert.stub(FormatDateSpy).was.called_with(mw.language, 'U', '20211017 21:40') + + DateExt.readTimestamp('2024-11-24T15:38:01') + assert.stub(FormatDateSpy).was.called_with(mw.language, 'U', '2024112415:38:01') + + DateExt.readTimestamp('2024-11-24T15:38:01.999Z') + assert.stub(FormatDateSpy).was.called_with(mw.language, 'U', '2024112415:38:01.999Z') end) end) diff --git a/standard/date_ext.lua b/standard/date_ext.lua index 0ac29fbe79c..abcc3df5e15 100644 --- a/standard/date_ext.lua +++ b/standard/date_ext.lua @@ -52,7 +52,9 @@ function DateExt.readTimestamp(dateInput) -- Extracts the '-4:00' out of EDT local tzTemplateOffset = dateInput:match('data%-tz%=[\"\']([%d%-%+%:]+)[\"\']') - local datePart = (mw.text.split(dateInput, '<', true)[1]):gsub('-', '') + local datePart = (mw.text.split(dateInput, '<', true)[1]) + :gsub('-', '') + :gsub('T', '') local timestampString = mw.getContentLanguage():formatDate('U', datePart .. (tzTemplateOffset or '')) return tonumber(timestampString) end