-
-
Notifications
You must be signed in to change notification settings - Fork 91
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: Add fullDateWithWeekday, weekday and weekdayShort formatters #400
feat: Add fullDateWithWeekday, weekday and weekdayShort formatters #400
Conversation
Codecov Report
@@ Coverage Diff @@
## master #400 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 692 692
Branches 76 76
=========================================
Hits 692 692
Continue to review full report at Codecov.
|
… + general doc tidy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run yarn prettier --write './packages/**/*.{js,jsx,ts,tsx,json,css,md,mdx}'
.
And also what was the motivation of updating example comments?
Russian output is ok. For hijiri and jallali will wait for some native speaker open issue 🤷♂️
Or allow changing from maintainers in PR settings.
Co-authored-by: Dmitriy Kovalenko <[email protected]>
Co-authored-by: Shahab <[email protected]>
@c0m1t thanks for taking a look at the Jalaali! Unfortunately, the test is currently failing based on the new formatter string. Would you be able to take a quick look and either update the formatter string or the test? Much appreciated :) |
@dmtrKovalenko, thanks for reviewing!
The previous examples were inaccurate so (in most cases) I have aligned the examples with the test assertions. For example: Previous date-io/packages/core/IUtils.d.ts Lines 2 to 3 in e8ce35c
Test assertion (unchanged): date-io/__tests__/formats.test.ts Line 40 in e8ce35c
Note that the month abbreviation is used, whereas the docs show that the full month is used. This inaccuracy is a show stopper for a11y text-to-speech, hence the update. I'll comment on each change with the reason for the change (as some vary). Please let me know if there are any issues with any of the individual changes. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rationale for individual doc changes...
export interface DateIOFormats<TLibFormatToken = string> { | ||
/** Localized full date, useful for accessibility @example "January 1st, 2019" */ | ||
/** Localized full date @example "Jan 1, 2019" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate and did not match test assertion
normalDate: TLibFormatToken; | ||
/** Date format string with weekday, month and day of month @example "Wed, Jan 1st" */ | ||
/** Date format string with weekday, month and day of month @example "Wed, Jan 1" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate and did not match test assertion
normalDateWithWeekday: TLibFormatToken; | ||
/** Shorter day format @example "1 January" */ | ||
/** Shorter day format @example "Jan 1" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate and did not match test assertion
@@ -15,37 +21,41 @@ export interface DateIOFormats<TLibFormatToken = string> { | |||
monthShort: TLibFormatToken; | |||
/** Short month format string @example "January 2018" */ | |||
monthAndYear: TLibFormatToken; | |||
/** Month with date format string @example "January 1st" */ | |||
/** Month with date format string @example "January 1" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate and did not match test assertion
dayOfMonth: TLibFormatToken; | ||
/** Hours format string @example "11" */ | ||
hours12h: TLibFormatToken; | ||
/** Hours format string @example "23" */ | ||
hours24h: TLibFormatToken; | ||
/** Minutes format string @example "59" */ | ||
/** Minutes format string @example "44" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aligned with test assertion (no real need in this case, but why not 😄 ).
fullTime24h: TLibFormatToken; | ||
/** Date & time format string with localized time @example "2018, Jan 1st 11:44 PM" */ | ||
/** Date & time format string with localized time @example "Jan 1, 2018 11:44 PM" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate and did not match test assertion
fullDateTime24h: TLibFormatToken; | ||
/** Localized keyboard input friendly date format @example "2019/01/01" */ | ||
/** Localized keyboard input friendly date format @example "02/13/2020 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate for en-US
. However, I've deviated from the test assertion to better imply the mm/dd/yyyy
order here (ie. 13
implies dd
as cannot be mm
).
keyboardDate: TLibFormatToken; | ||
/** Localized keyboard input friendly date/time format @example "2019/01/01 23:44" */ | ||
/** Localized keyboard input friendly date/time format @example "02/13/2020 23:44" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate for en-US
. However, I've deviated from the test assertion to better imply the mm/dd/yyyy
order here (ie. 13
implies dd
as cannot be mm
).
keyboardDateTime: TLibFormatToken; | ||
/** Not Localized keyboard input friendly date/time 12h format @example "2019/01/01 11:44 PM" */ | ||
/** Partially localized keyboard input friendly date/time 12h format @example "02/13/2020 11:44 PM" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate for en-US
. However, I've deviated from the test assertion to better imply the mm/dd/yyyy
order here (ie. 13
implies dd
as cannot be mm
).
I've also changed Not Localized
to Partially localized
to better reflect the use of the localized formatter for the date part.
keyboardDateTime12h: TLibFormatToken; | ||
/** Not localized keyboard input friendly date/time 24h format @example "2019/01/01 23:44" */ | ||
/** Partially localized keyboard input friendly date/time 24h format @example "02/13/2020 23:44" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prev example was inaccurate for en-US
. However, I've deviated from the test assertion to better imply the mm/dd/yyyy
order here (ie. 13
implies dd
as cannot be mm
).
I've also changed Not Localized
to Partially localized
to better reflect the use of the localized formatter for the date part.
What the status of this PR? CI is failing. Would you be able to finish it? |
@dmtrKovalenko the failing test is due to the Jalaali change by @c0m1t (I've requested they take a look). If you're confident enough to fix it, please do, either:
As I don't read the language, I can't tell which of these is correct. ALSO:
🤷♂️ 🤷♂️ 🤷♂️ 😄 (Btw... |
I forgot I don't know if people use the But this is now how we made |
I am not speaking those languages too, so I`d prefer just fix the tests as is (already done it) and wait for somebody (cc @c0m1t 🙏) open a PR that fixes translations... |
Thanks @philipbulley for your awesome input! ❤️ |
@dmtrKovalenko no probs, it's my pleasure 👍 Thanks also to @c0m1t ! |
Addresses #399
I've used the following formatter strings:
fullDateWithWeekday
weekday
weekdayShort
PPPP
EEEE
EEE
dddd, LL
*dddd
ddd
DDDD
cccc
ccc
dddd, LL
dddd
ddd
jYYYY, jMMMM Do, dddd
*dddd
ddd
iYYYY, iMMMM Do, dddd
*dddd
ddd
fullDateWithWeekday
, so I have improvised by addingdddd
and documentedfullDateWithWeekday
as being "Partially localized". This may not be ideal across all locales — I see you've done something similar withkeyboardDateTime12h
, etc. I imagine this won't be a problem.formats.test
. I've used a 'best guess' and have just copied the received values directly into the tests. Do you have anyone who can verify?Please let me know if you'd like to see any changes, or feel free to edit.