Skip to content

Commit cb2f157

Browse files
committed
fix: add A → a replacement in dateFns localeParse for use12Hours support
When use12Hours is enabled, rc-picker internally injects uppercase A (moment.js AM/PM token) into the format string. date-fns uses lowercase a for AM/PM, so passing A through causes: RangeError: Format string contains an unescaped latin alphabet character `A` localeParse already converts other moment tokens (Y→y, D→d, etc.) but was missing A→a. This adds it. Fixes #964
1 parent 738bcac commit cb2f157

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/generate/dateFns.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const localeParse = (format: string) => {
4141
.replace(/D/g, 'd')
4242
.replace(/gggg/, 'yyyy')
4343
.replace(/g/g, 'G')
44-
.replace(/([Ww])o/g, 'wo');
44+
.replace(/([Ww])o/g, 'wo')
45+
.replace(/A/g, 'a');
4546
};
4647

4748
const parse = (text: string, format: string, locale: string) => {

0 commit comments

Comments
 (0)