Add missing padding to 'YYYY' format
Adds padding to the year component when formatted with `'YYYY'`, similar to how padding is handled for `'MM'` and `'DD'`.

Fixes #2230
**Describe the bug**
If the year component of a date is less than 1000, the leading zeroes are omitted when trying to format the year with `'YYYY'`.

E.g.:

```js
dayjs(Date.parse('0001-01-01')).format('YYYY-MM-DD') //=> '1-01-01'
dayjs(Date.parse('0010-01-01')).format('YYYY-MM-DD') //=> '10-01-01'
dayjs(Date.parse('0100-01-01')).format('YYYY-MM-DD') //=> '100-01-01'
```

**Expected behavior**
`'YYYY'` in the format string should place leading zeroes to make sure the year takes up 4 digits in the output.

E.g.:

```js
dayjs(Date.parse('0001-01-01')).format('YYYY-MM-DD') //=> '0001-01-01'
dayjs(Date.parse('0010-01-01')).format('YYYY-MM-DD') //=> '0010-01-01'
dayjs(Date.parse('0100-01-01')).format('YYYY-MM-DD') //=> '0100-01-01'
```

**Information**
 - Day.js Version: v1.11.7
 - OS: Windows 11
 - Browser Firefox, NodeJS console
 - Time zone: CET (UTC +1), Central European Time (Europe/Stockholm) (DST not in effect)

'YYYY' results in missing leading zeroes when year <1000
diff --git a/src/index.js b/src/index.js
index 19c409078..ba74b8b66 100644
--- a/src/index.js
+++ b/src/index.js
@@ -280,7 +280,7 @@ class Dayjs {
 
     const matches = {
       YY: String(this.$y).slice(-2),
-      YYYY: this.$y,
+      YYYY: Utils.s(this.$y, 4, '0'),
       M: $M + 1,
       MM: Utils.s($M + 1, 2, '0'),
       MMM: getShort(locale.monthsShort, $M, months, 3),

diff --git a/test/display.test.js b/test/display.test.js
index 7eb48fe82..86a978dfc 100644
--- a/test/display.test.js
+++ b/test/display.test.js
@@ -260,3 +260,15 @@ it('As JSON -> toJSON', () => {
 it('As ISO 8601 String -> toISOString e.g. 2013-02-04T22:44:30.652Z', () => {
   expect(dayjs().toISOString()).toBe(moment().toISOString())
 })
+
+it('Year 1 formatted with YYYY should pad with zeroes', () => {
+  const date = new Date(1, 0, 1)
+  date.setUTCFullYear(1) // Required because 0-99 are parsed as 19xx in JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#year
+  expect(dayjs(date).format('YYYY')).toBe('0001')
+})
+
+it('Year 1 formatting matches moment format', () => {
+  const date = new Date(1, 0, 1)
+  date.setUTCFullYear(1)
+  expect(dayjs(date).format('YYYY')).toBe(moment(date).format('YYYY'))
+})

{"test/display.test.js": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"test/timezone.test.js:Add Time days (DST)": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/de.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/is.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/sk.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/advancedFormat.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/weekYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isSameOrBefore.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/pluralGetSet.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js:Diff (DST)": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/bigIntSupport.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/keys.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/zh-tw.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/utils.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/relativeTime.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/parse.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/localizedFormat.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/updateLocale.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/constructor.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/weekday.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/zh-hk.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isLeapYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/query.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/localeData.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js:UTC diff in DST": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/zh.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ja.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/declarations.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-kw.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-dz.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/timezone.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ru.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/bn.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/dayOfYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js:UTC add day in DST": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/manipulate.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/issues/issue2027.swapped-order.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/cs.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/en.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/get-set.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/he.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/utc.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/bn-bd.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/quarterOfYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/objectSupport.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/fi.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-tn.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-ma.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/sv.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/toArray.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js:Utc Offset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-sa.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/bg.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/issues/issue2027.correct-order.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/utc-utcOffset.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/sr-cyrl.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/br.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isMoment.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isYesterday.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/pl.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/toObject.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/sr.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/it-ch.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/preParsePostFormat.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isSameOrAfter.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/weekOfYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/comparison.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/calendar.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/et.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/hu.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isTomorrow.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/timezone.test.js:UTC and utcOffset": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/arraySupport.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isToday.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/hr.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-ly.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ku.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/badMutable.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/sv-fi.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/customParseFormat.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/duration.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isoWeek.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar-iq.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/minMax.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isoWeeksInYear.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/uk.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/buddhistEra.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/devHelper.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/lt.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/zh-cn.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/locale/ar.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "test/plugin/isBetween.test.js": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"test/display.test.js": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"passed_count": 95, "failed_count": 0, "skipped_count": 0, "passed_tests": ["test/timezone.test.js:Add Time days (DST)", "test/locale/sk.test.js", "test/plugin/weekYear.test.js", "test/plugin/isSameOrBefore.test.js", "test/plugin/pluralGetSet.test.js", "test/timezone.test.js:Diff (DST)", "test/plugin/bigIntSupport.test.js", "test/locale/keys.test.js", "test/locale/zh-tw.test.js", "test/parse.test.js", "test/plugin/weekday.test.js", "test/locale/zh-hk.test.js", "test/plugin/isLeapYear.test.js", "test/query.test.js", "test/plugin/localeData.test.js", "test/timezone.test.js:UTC diff in DST", "test/locale/zh.test.js", "test/plugin/declarations.test.js", "test/locale/bn.test.js", "test/plugin/dayOfYear.test.js", "test/locale/en.test.js", "test/get-set.test.js", "test/locale/he.test.js", "test/locale/bn-bd.test.js", "test/plugin/quarterOfYear.test.js", "test/plugin/objectSupport.test.js", "test/locale/fi.test.js", "test/locale/ar-sa.test.js", "test/issues/issue2027.correct-order.test.js", "test/plugin/utc-utcOffset.test.js", "test/locale/br.test.js", "test/locale/pl.test.js", "test/plugin/toObject.test.js", "test/plugin/isSameOrAfter.test.js", "test/plugin/weekOfYear.test.js", "test/plugin/calendar.test.js", "test/plugin/arraySupport.test.js", "test/plugin/isToday.test.js", "test/locale/hr.test.js", "test/locale/ar-ly.test.js", "test/locale.test.js", "test/plugin/customParseFormat.test.js", "test/plugin/duration.test.js", "test/plugin/isoWeeksInYear.test.js", "test/locale/uk.test.js", "test/locale/zh-cn.test.js", "test/plugin/isBetween.test.js", "test/plugin.test.js", "test/locale/de.test.js", "test/locale/is.test.js", "test/plugin/advancedFormat.test.js", "test/timezone.test.js", "test/utils.test.js", "test/plugin/relativeTime.test.js", "test/plugin/localizedFormat.test.js", "test/plugin/updateLocale.test.js", "test/constructor.test.js", "test/locale/ja.test.js", "test/locale/ar-kw.test.js", "test/locale/ar-dz.test.js", "test/plugin/timezone.test.js", "test/locale/ru.test.js", "test/timezone.test.js:UTC add day in DST", "test/manipulate.test.js", "test/issues/issue2027.swapped-order.test.js", "test/locale/cs.test.js", "test/plugin/utc.test.js", "test/locale/ar-tn.test.js", "test/locale/ar-ma.test.js", "test/locale/sv.test.js", "test/plugin/toArray.test.js", "test/timezone.test.js:Utc Offset", "test/locale/bg.test.js", "test/locale/sr-cyrl.test.js", "test/plugin/isMoment.test.js", "test/plugin/isYesterday.test.js", "test/locale/sr.test.js", "test/locale/it-ch.test.js", "test/plugin/preParsePostFormat.test.js", "test/comparison.test.js", "test/locale/et.test.js", "test/locale/hu.test.js", "test/plugin/isTomorrow.test.js", "test/timezone.test.js:UTC and utcOffset", "test/locale/ku.test.js", "test/plugin/badMutable.test.js", "test/locale/sv-fi.test.js", "test/plugin/isoWeek.test.js", "test/locale/ar-iq.test.js", "test/plugin/minMax.test.js", "test/plugin/buddhistEra.test.js", "test/display.test.js", "test/plugin/devHelper.test.js", "test/locale/lt.test.js", "test/locale/ar.test.js"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 94, "failed_count": 1, "skipped_count": 0, "passed_tests": ["test/timezone.test.js:Add Time days (DST)", "test/locale/sk.test.js", "test/plugin/weekYear.test.js", "test/plugin/isSameOrBefore.test.js", "test/plugin/pluralGetSet.test.js", "test/timezone.test.js:Diff (DST)", "test/plugin/bigIntSupport.test.js", "test/locale/keys.test.js", "test/locale/zh-tw.test.js", "test/parse.test.js", "test/plugin/weekday.test.js", "test/locale/zh-hk.test.js", "test/plugin/isLeapYear.test.js", "test/query.test.js", "test/plugin/localeData.test.js", "test/timezone.test.js:UTC diff in DST", "test/locale/zh.test.js", "test/plugin/declarations.test.js", "test/locale/bn.test.js", "test/plugin/dayOfYear.test.js", "test/locale/en.test.js", "test/get-set.test.js", "test/locale/he.test.js", "test/locale/bn-bd.test.js", "test/plugin/quarterOfYear.test.js", "test/plugin/objectSupport.test.js", "test/locale/fi.test.js", "test/locale/ar-sa.test.js", "test/issues/issue2027.correct-order.test.js", "test/plugin/utc-utcOffset.test.js", "test/locale/br.test.js", "test/locale/pl.test.js", "test/plugin/toObject.test.js", "test/plugin/isSameOrAfter.test.js", "test/plugin/weekOfYear.test.js", "test/plugin/calendar.test.js", "test/plugin/arraySupport.test.js", "test/plugin/isToday.test.js", "test/locale/hr.test.js", "test/locale/ar-ly.test.js", "test/locale.test.js", "test/plugin/customParseFormat.test.js", "test/plugin/duration.test.js", "test/plugin/isoWeeksInYear.test.js", "test/locale/uk.test.js", "test/locale/zh-cn.test.js", "test/plugin/isBetween.test.js", "test/plugin.test.js", "test/locale/de.test.js", "test/locale/is.test.js", "test/plugin/advancedFormat.test.js", "test/timezone.test.js", "test/utils.test.js", "test/plugin/relativeTime.test.js", "test/plugin/localizedFormat.test.js", "test/plugin/updateLocale.test.js", "test/constructor.test.js", "test/locale/ja.test.js", "test/locale/ar-kw.test.js", "test/locale/ar-dz.test.js", "test/plugin/timezone.test.js", "test/locale/ru.test.js", "test/timezone.test.js:UTC add day in DST", "test/manipulate.test.js", "test/issues/issue2027.swapped-order.test.js", "test/locale/cs.test.js", "test/plugin/utc.test.js", "test/locale/ar-tn.test.js", "test/locale/ar-ma.test.js", "test/locale/sv.test.js", "test/plugin/toArray.test.js", "test/timezone.test.js:Utc Offset", "test/locale/bg.test.js", "test/locale/sr-cyrl.test.js", "test/plugin/isMoment.test.js", "test/plugin/isYesterday.test.js", "test/locale/sr.test.js", "test/locale/it-ch.test.js", "test/plugin/preParsePostFormat.test.js", "test/comparison.test.js", "test/locale/et.test.js", "test/plugin/isTomorrow.test.js", "test/locale/hu.test.js", "test/timezone.test.js:UTC and utcOffset", "test/locale/ku.test.js", "test/plugin/badMutable.test.js", "test/locale/sv-fi.test.js", "test/plugin/isoWeek.test.js", "test/locale/ar-iq.test.js", "test/plugin/minMax.test.js", "test/plugin/buddhistEra.test.js", "test/plugin/devHelper.test.js", "test/locale/lt.test.js", "test/locale/ar.test.js"], "failed_tests": ["test/display.test.js"], "skipped_tests": []}
{"passed_count": 95, "failed_count": 0, "skipped_count": 0, "passed_tests": ["test/timezone.test.js:Add Time days (DST)", "test/locale/sk.test.js", "test/plugin/weekYear.test.js", "test/plugin/isSameOrBefore.test.js", "test/plugin/pluralGetSet.test.js", "test/timezone.test.js:Diff (DST)", "test/plugin/bigIntSupport.test.js", "test/locale/keys.test.js", "test/locale/zh-tw.test.js", "test/parse.test.js", "test/plugin/weekday.test.js", "test/locale/zh-hk.test.js", "test/plugin/isLeapYear.test.js", "test/query.test.js", "test/plugin/localeData.test.js", "test/timezone.test.js:UTC diff in DST", "test/locale/zh.test.js", "test/plugin/declarations.test.js", "test/locale/bn.test.js", "test/plugin/dayOfYear.test.js", "test/locale/en.test.js", "test/get-set.test.js", "test/locale/he.test.js", "test/locale/bn-bd.test.js", "test/plugin/quarterOfYear.test.js", "test/plugin/objectSupport.test.js", "test/locale/fi.test.js", "test/locale/ar-sa.test.js", "test/issues/issue2027.correct-order.test.js", "test/plugin/utc-utcOffset.test.js", "test/locale/br.test.js", "test/locale/pl.test.js", "test/plugin/toObject.test.js", "test/plugin/isSameOrAfter.test.js", "test/plugin/weekOfYear.test.js", "test/plugin/calendar.test.js", "test/plugin/arraySupport.test.js", "test/plugin/isToday.test.js", "test/locale/hr.test.js", "test/locale/ar-ly.test.js", "test/locale.test.js", "test/plugin/customParseFormat.test.js", "test/plugin/duration.test.js", "test/plugin/isoWeeksInYear.test.js", "test/locale/uk.test.js", "test/locale/zh-cn.test.js", "test/plugin/isBetween.test.js", "test/plugin.test.js", "test/locale/de.test.js", "test/locale/is.test.js", "test/plugin/advancedFormat.test.js", "test/timezone.test.js", "test/utils.test.js", "test/plugin/relativeTime.test.js", "test/plugin/localizedFormat.test.js", "test/plugin/updateLocale.test.js", "test/constructor.test.js", "test/locale/ja.test.js", "test/locale/ar-kw.test.js", "test/locale/ar-dz.test.js", "test/plugin/timezone.test.js", "test/locale/ru.test.js", "test/timezone.test.js:UTC add day in DST", "test/manipulate.test.js", "test/issues/issue2027.swapped-order.test.js", "test/locale/cs.test.js", "test/plugin/utc.test.js", "test/locale/ar-tn.test.js", "test/locale/ar-ma.test.js", "test/locale/sv.test.js", "test/plugin/toArray.test.js", "test/timezone.test.js:Utc Offset", "test/locale/bg.test.js", "test/locale/sr-cyrl.test.js", "test/plugin/isMoment.test.js", "test/plugin/isYesterday.test.js", "test/locale/sr.test.js", "test/locale/it-ch.test.js", "test/plugin/preParsePostFormat.test.js", "test/comparison.test.js", "test/locale/et.test.js", "test/plugin/isTomorrow.test.js", "test/locale/hu.test.js", "test/timezone.test.js:UTC and utcOffset", "test/locale/ku.test.js", "test/plugin/badMutable.test.js", "test/locale/sv-fi.test.js", "test/plugin/isoWeek.test.js", "test/locale/ar-iq.test.js", "test/plugin/minMax.test.js", "test/plugin/buddhistEra.test.js", "test/display.test.js", "test/plugin/devHelper.test.js", "test/locale/lt.test.js", "test/locale/ar.test.js"], "failed_tests": [], "skipped_tests": []}