File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -222,4 +222,7 @@ describe("format with a timezone", () => {
222
222
} )
223
223
) . toBe ( "02:30:00+0000" )
224
224
} )
225
+ it ( "can render a double character zero with leading zeros in zh (#41)" , ( ) => {
226
+ expect ( format ( "2022-04-10" , "YYYY-MM" , "zh" ) ) . toBe ( "2022-04" )
227
+ } )
225
228
} )
Original file line number Diff line number Diff line change @@ -177,11 +177,9 @@ export function fill(
177
177
if ( partName === "hour" && token === "H" ) {
178
178
return value . replace ( / ^ 0 / , "" )
179
179
}
180
- if (
181
- ( partName === "minute" || partName === "second" ) &&
182
- ( token === "mm" || token === "ss" ) &&
183
- value . length === 1
184
- ) {
180
+ if ( [ "mm" , "ss" , "MM" ] . includes ( token ) && value . length === 1 ) {
181
+ // Some tokens are supposed to have leading zeros, but Intl doesn't
182
+ // always return them, depending on the locale and the format.
185
183
return `0${ value } `
186
184
}
187
185
if ( partName === "dayPeriod" ) {
You can’t perform that action at this time.
0 commit comments