Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(calendar): support token dateformats #2324

Merged
merged 4 commits into from
Apr 17, 2022

Conversation

lubber-de
Copy link
Member

@lubber-de lubber-de commented Apr 15, 2022

Description

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

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.

Testcase

https://jsfiddle.net/lubber/e476qpnm/6/

Closes

#508
#568
#1523
#1645
#1218
#2268

@lubber-de lubber-de added type/feat Any feature requests or improvements lang/javascript Anything involving JavaScript state/awaiting-reviews Pull requests which are waiting for reviews state/awaiting-docs Pull requests which need doc changes/additions tag/breaking-change Any pull request which is waiting for a breaking change release labels Apr 15, 2022
@lubber-de lubber-de added this to the 2.9.0 milestone Apr 15, 2022
@lubber-de lubber-de changed the title feat(calender): support token dateformats feat(calendar): support token dateformats Apr 15, 2022
exoego
exoego previously approved these changes Apr 15, 2022
Copy link
Contributor

@exoego exoego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👍

@lubber-de
Copy link
Member Author

lubber-de commented Apr 16, 2022

@exoego I made the time format inside cell selection independent of the output format and provided an additional formattedDate behavior by 76b68b9

Please review again.

@lubber-de lubber-de requested a review from exoego April 16, 2022 09:33
@lubber-de lubber-de merged commit 721e0ff into fomantic:develop Apr 17, 2022
@lubber-de lubber-de deleted the dateFormatFromString branch April 17, 2022 16:27
@lubber-de lubber-de removed the state/awaiting-reviews Pull requests which are waiting for reviews label Apr 17, 2022
@lubber-de
Copy link
Member Author

Docs added by fomantic/Fomantic-UI-Docs#348

@lubber-de lubber-de added state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo and removed state/awaiting-docs Pull requests which need doc changes/additions labels May 28, 2022
lubber-de added a commit to fomantic/Fomantic-UI-Docs that referenced this pull request Jun 4, 2022
Added new token format example and adjusted related other examples like 24h format as of fomantic/Fomantic-UI#2324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/javascript Anything involving JavaScript state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo tag/breaking-change Any pull request which is waiting for a breaking change release type/feat Any feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants