fix: Pad formatted year string with zeros
This pull request fixes formatting of date with pattern "YYYY" for years less than 1000
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
f3e671f) to head (e1e64bf). Report is 557 commits behind head on dev.
Additional details and impacted files
@@ Coverage Diff @@
## dev #597 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 154 154
Lines 982 982
Branches 140 140
=========================================
Hits 982 982
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I just stumbled into this issue. It would be nice to get this merged in
Not really good. You can pad number on demand in your particular project but internationally years before 1000 are used unpadded
Not really good. You can pad number on demand in your particular project but internationally years before 1000 are used unpadded
My intention is to keep compatibility with moment.js API, which has YYYY format for 4-digit years and Y to display unpadded year. Moreover, current formatting leads to some errors like
const initial = new Date('0001-01-01');
const initial_dayjs = dayjs(initial);
const formated_initial = initial_dayjs.format('YYYY-MM-DD'); // produces 1-01-01
const parsed = dayjs(formated_initial);
const formated_result = initial_dayjs.format('YYYY-MM-DD'); // produces 2001-01-01