-
Notifications
You must be signed in to change notification settings - Fork 603
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
Date: Add formatDateToParts #700
Conversation
1b039ba
to
5ee25cb
Compare
9a1b387
to
1cd9bd4
Compare
1cd9bd4
to
6118055
Compare
ff349bd
to
c11b38a
Compare
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.
I started reviewing, then got dragged into a meeting. Didn't get very far, but hopefully the existing comments will help.
@@ -89,7 +89,7 @@ var enFormatter = Globalize( "en" ).dateFormatter(), | |||
deFormatter = Globalize( "de" ).dateFormatter(); | |||
|
|||
enFormatter( new Date( 2010, 10, 30, 17, 55 ) ); | |||
// > "11/30/2010, 5:55 PM" | |||
// > "11/30/2010" |
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.
Should the line above still pass the time to the Date constructor? Probably applies to various other examples in this file (and others?) as well.
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.
The time part of the Date constructor is irrelevant and could be removed. 👍
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.
|
||
### Example | ||
|
||
Prior to using any date methods, you must load |
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.
Do all docs have this note in the example section? Seems like important information that could be pulled up.
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.
Yeap, other modules/fns have the same statement.
formatter( new Date( 2010, 10, 30, 17, 55 ) ).map(({type, value}) => { | ||
switch ( type ) { | ||
case "year": return `<strong>${value}</strong>`; | ||
default : return value; |
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.
misplaced space in front of the colon
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.
Thx a9bc0b5
|
||
- `day` | ||
|
||
The string used for the day, e.g., `"17"`, `"١٦"`. |
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.
Could compress this section a lot by putting the type of description on one line.
- `day`: The string used for the day, e.g., `"17"`, `"١٦"`.
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.
Yeap, I think it needs overall improvement. I dislike the current format of the API, I am wondering if we had something like https://github.com/rxaviers/relative-time#formatdate-options instead.
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.
Let's track overall docs improvement in a separate PR.
Globalize.locale( "en" ); | ||
formatter = Globalize.dateToPartsFormatter(); | ||
|
||
formatter( new Date( 2010, 10, 30, 17, 55 ) ).map(({type, value}) => { |
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.
This is a great example, but it doesn't output the time, which seems harder to implement, since a join("")
wouldn't be enough. Would be great to have an example including time.
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.
since a
join("")
wouldn't be enough
Why? Check the parts output of a date and time case https://github.com/globalizejs/globalize/pull/700/files#diff-5e625c00d307f2b886e1b33225953053R165
Having said that, I think it's valid to include a date and time example.
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.
@jzaefferer thanks for your review |
d9b8c40
to
9408bff
Compare
@@ -4,6 +4,7 @@ | |||
"number-label": "Número", | |||
"currency-label": "Moneda", | |||
"date-label": "Fecha", | |||
"date-to-parts-label": "Fecha (note el mes destacado en negro, el marcador de html se agregó utilizando dateToPartsFormatter)", |
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.
Thanks @lwelti
@@ -4,6 +4,7 @@ | |||
"number-label": "Zahl", | |||
"currency-label": "Währung", | |||
"date-label": "Datum", | |||
"date-to-parts-label": "Datum (beachten Sie den hervorgehobenen Monat, das Markup wurde mit dateToPartsFormatter hinzugefügt)", |
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.
Thanks @jzaefferer
9408bff
to
8eed86d
Compare
When dateToPartsFormatter was added, dateFormatter became an alias to it. Although globalize-compiler can handle it by using `.compileExtracts()`, it doesn't by using `.compile()` and passing `formattersAndParsers` argument. This update fixed that. Amends e4234a7 Ref globalizejs#678 Ref globalizejs#697 Ref globalizejs#700
Supersedes #697, Fixes #678
List of part types, its respective CLDR date fields, and comparison with Intl DateTimeFormat formatToParts.
List of part types and the corresponding CLDR date field patterns.
Checklist:
Checklist