-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(calendar): support token dateformats
This PR adds support to use token strings as a date formatter. It's still possible to provide functions as before. The base idea is adopted from https://blog.stevenlevithan.com/archives/javascript-date-format Now you can use something like ```javascript formatter: { date: '"Intergalactic Date:" D.M.YYYY' } ``` Usable Tokens (i compared popular big date libs like momentjs, date-fns, luxon and dayjs to make sure to basically match the same syntax) |Description|Token|Resultset| |-|-|-| |Day of Week|d|0-6| |Day of Week (2 char text)|dd|Su - Sa| |Day of Week (3 char text)|ddd|Sun - Sat| |Day of Week (Full text)|dddd|Sunday - Saturday| |Day of Month |D|1 to 31| |Day of Month (Leading zero)|DD|01-31| |Day suffix|S|st,nd,rd,th| |Month |M|1 to 12| |Month (Leading zero)|MM|01-12| |Month (3 char text)|MMM|Jan-Dec| |Month (Full text)|MMMM|January-December| |Year|YYYY or Y|2022| |Year (2 Digits)|YY|22| |Week|w|1-53| |Week (Leading zero)|ww|01-53| |Hour (12h Format)|h|1-12| |Hour (12h Format, Leading zero)|hh|01-12| |Hour (24h Format)|H|0-23| |Hour (24h Format, Leading zero)|HH|00-23| |Minute|m|0-59| |Minute (Leading zero)|mm|00-59| |Second|s|0-59| |Second (Leading zero)|ss|00-59| |AM/PM|A|AM-PM| |AM/PM (lowercase)|a|am-pm| |Custom Text|Wrap in double or single quotes|Your text without quotes| I removed the `ampm` setting, because it is now controllable via the `A` or `a` token.
- Loading branch information
Showing
1 changed file
with
77 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters