[READ-ONLY] Mirror of https://github.com/probablykasper/date-picker-svelte. Date and time picker for Svelte date-picker-svelte.kasper.space
calendar date date-picker date-time-picker datepicker package svelte time
0

Configure Feed

Select the types of activity you want to include in your feed.

Add 'yy' format (#61)

* Add 'yy' format

* Fix 'yy' parsing

---------

Co-authored-by: Kasper <kasperkh.kh@gmail.com>

authored by

erezarnon
Kasper
and committed by
GitHub
(Jul 11, 2023, 12:45 AM +0200) c271ef37 6d5225ad

+8
+7
src/lib/parse.ts
··· 57 57 function parseToken(token: FormatToken) { 58 58 if (typeof token === 'string') { 59 59 parseString(token) 60 + } else if (token.id === 'yy') { 61 + const value = parseUint(/^[0-9]{2}/, 0, 99) 62 + if (value !== null) year = 2000 + value 60 63 } else if (token.id === 'yyyy') { 61 64 const value = parseUint(/^[0-9]{4}/, 0, 9999) 62 65 if (value !== null) year = value ··· 102 105 { 103 106 id: 'yyyy', 104 107 toString: (d: Date) => d.getFullYear().toString(), 108 + }, 109 + { 110 + id: 'yy', 111 + toString: (d: Date) => d.getFullYear().toString().slice(-2), 105 112 }, 106 113 { 107 114 id: 'MM',
+1
src/routes/docs/+page.md
··· 50 50 | Pattern | Result example | 51 51 | :------ | :------------- | 52 52 | `yyyy` | 2021 | 53 + | `yy` | 21 | 53 54 | `MM` | 12 | 54 55 | `dd` | 31 | 55 56 | `HH` | 23 |