Skip to content

Commit 582a66b

Browse files
daedalus28claude
andcommitted
Add test for AM/PM format token conversion in date-fns adapter
Verifies that localeParse converts uppercase A (moment-style AM/PM) to lowercase a (date-fns) so that both format() and parse() work correctly with 12-hour time formats. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cb2f157 commit 582a66b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/generate.spec.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,19 @@ describe('Generate:date-fns', () => {
335335
expect(dateFnsGenerateConfig.locale.getWeekFirstDay('it_IT')).toEqual(1);
336336
expect(dateFnsGenerateConfig.locale.getWeekFirstDay('fr_FR')).toEqual(1);
337337
});
338+
339+
it('format and parse with AM/PM (uppercase A)', () => {
340+
const date = new Date(2000, 0, 1, 14, 30, 0);
341+
342+
// Format with uppercase A (moment-style) should produce lowercase am/pm output
343+
const formatted = dateFnsGenerateConfig.locale.format('en_US', date, 'YYYY-MM-DD hh:mm:ss A');
344+
expect(formatted).toEqual('2000-01-01 02:30:00 PM');
345+
346+
// Parse with uppercase A should also work without throwing
347+
const parsed = dateFnsGenerateConfig.locale.parse('en_US', '2000-01-01 02:30:00 PM', [
348+
'YYYY-MM-DD hh:mm:ss A',
349+
]);
350+
expect(dateFnsGenerateConfig.getHour(parsed)).toEqual(14);
351+
expect(dateFnsGenerateConfig.getMinute(parsed)).toEqual(30);
352+
});
338353
});

0 commit comments

Comments
 (0)