-
Notifications
You must be signed in to change notification settings - Fork 596
Fixed issue 272 Handle DateTime in same skeleton. #426
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
Changes from all commits
f624add
ddd187a
ca8489a
0e459b7
93cb191
3b50fcd
f325299
306b57e
45a2ed8
2919ab6
c3056de
00673c1
d7d6136
dd4236d
e573063
4876f8d
d64b3dc
e9984fa
5c096d5
6d0f96c
6fce167
8929507
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,19 +24,54 @@ define([ | |
| * - { datetime: "full" } returns "EEEE, MMMM d, y 'at' h:mm:ss a zzzz"; | ||
| * - { pattern: "dd/mm" } returns "dd/mm"; | ||
| */ | ||
|
|
||
| return function( pattern, cldr ) { | ||
| var result; | ||
| var dateSkeleton, result, skeleton, timeSkeleton, type; | ||
|
|
||
| function combineDateTime( type, datePattern, timePattern ) { | ||
| return formatMessage( | ||
| cldr.main([ | ||
| "dates/calendars/gregorian/dateTimeFormats", | ||
| type | ||
| ]), | ||
| [ timePattern, datePattern ] | ||
| ); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
First, check for availableFormats. Therefore, keep the above. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rxaviers sir, Sir here it is throwing error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nope. There may be skeletons containing both date and time parts. So, we need to follow what's in the specification, which says "if the availableFormats data does not include a dateFormatItem whose skeleton matches the same set of fields" that we should look for date and time separately. We need to find a way to technically do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example, otherwise you wouldn't get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rxaviers sir,
Yeah. Some cases will get missed through this method.
By skipping the path you mean adding the path for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct. |
||
|
|
||
| if ( typeof pattern === "string" ) { | ||
| pattern = { skeleton: pattern }; | ||
| } | ||
|
|
||
| switch ( true ) { | ||
| case "skeleton" in pattern: | ||
| skeleton = pattern.skeleton; | ||
| result = cldr.main([ | ||
| "dates/calendars/gregorian/dateTimeFormats/availableFormats", | ||
| pattern.skeleton | ||
| skeleton | ||
| ]); | ||
| if ( !result ) { | ||
| timeSkeleton = skeleton.split( /[^hHKkmsSAzZOvVXx]/ ).slice( -1 )[ 0 ]; | ||
| dateSkeleton = skeleton.split( /[^GyYuUrQqMLlwWdDFgEec]/ )[ 0 ]; | ||
| if ( /(MMMM|LLLL).*[Ec]/.test( dateSkeleton ) ) { | ||
| type = "full"; | ||
| } else if ( /MMMM/g.test( dateSkeleton ) ) { | ||
| type = "long"; | ||
| } else if ( /MMM/g.test( dateSkeleton ) || /LLL/g.test( dateSkeleton ) ) { | ||
| type = "medium"; | ||
| } else { | ||
| type = "short"; | ||
| } | ||
| result = combineDateTime( type, | ||
| cldr.main([ | ||
| "dates/calendars/gregorian/dateTimeFormats/availableFormats", | ||
| dateSkeleton | ||
| ]), | ||
| cldr.main([ | ||
| "dates/calendars/gregorian/dateTimeFormats/availableFormats", | ||
| timeSkeleton | ||
| ]) | ||
| ); | ||
| } | ||
| break; | ||
|
|
||
| case "date" in pattern: | ||
|
|
@@ -49,22 +84,10 @@ return function( pattern, cldr ) { | |
| break; | ||
|
|
||
| case "datetime" in pattern: | ||
| result = cldr.main([ | ||
| "dates/calendars/gregorian/dateTimeFormats", | ||
| pattern.datetime | ||
| ]); | ||
| if ( result ) { | ||
| result = formatMessage( result, [ | ||
| cldr.main([ | ||
| "dates/calendars/gregorian/timeFormats", | ||
| pattern.datetime | ||
| ]), | ||
| cldr.main([ | ||
| "dates/calendars/gregorian/dateFormats", | ||
| pattern.datetime | ||
| ]) | ||
| ]); | ||
| } | ||
| result = combineDateTime( pattern.datetime, | ||
| cldr.main([ "dates/calendars/gregorian/dateFormats", pattern.datetime ]), | ||
| cldr.main([ "dates/calendars/gregorian/timeFormats", pattern.datetime ]) | ||
| ); | ||
| break; | ||
|
|
||
| case "pattern" in pattern: | ||
|
|
||

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.
Alphabetical order is:
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.
Oopsie. Fixing.