-
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
Fixed issue 272 Handle DateTime in same skeleton. #426
Fixed issue 272 Handle DateTime in same skeleton. #426
Conversation
result = cldr.main([ | ||
"dates/calendars/gregorian/dateTimeFormats/availableFormats", | ||
pattern.skeleton | ||
]); |
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.
and if the availableFormats data does not include a dateFormatItem whose skeleton matches the same set of fields
First, check for availableFormats. Therefore, keep the above. If result === undefined
, keep going...
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.
@rxaviers sir,
Sir here it is throwing error E_MISSING_CLDR
error from cldr.main
itself and not returning undefined
for skeletons containing both date and time part. Hence we first have to check if skeleton entered has dateSkeleton or timeSkeleton or both before getting result. I am attaching a screenshot that will explain better.
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.
Hence we first have to check if skeleton entered has dateSkeleton or timeSkeleton or both before getting result. I am attaching a screenshot that will explain better.
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. cldr.main
itself doesn't throw E_MISSING_CLDR
error. The error is thrown by our validation. We could skip that path from the validation. See https://github.com/jquery/globalize/blob/master/src/date.js#L63.
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.
For example, otherwise you wouldn't get EHms
.
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.
@rxaviers sir,
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.
Yeah. Some cases will get missed through this method.
We could skip that path from the validation. See https://github.com/jquery/globalize/blob/master/src/date.js#L63.
By skipping the path you mean adding the path for availableFormats
here?
https://github.com/jquery/globalize/blob/master/src/date.js#L29
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.
By skipping the path you mean adding the path for availableFormats here?
https://github.com/jquery/globalize/blob/master/src/date.js#L29
Correct.
Below is what needs to be done: (from the spec)
Can you point me where in your code is this being performed?
Can you point me where in your code is this being performed?
|
Beyond the above comments, your code needs to follow our coding styles http://contribute.jquery.org/style-guide/js/. |
} | ||
return result; | ||
} | ||
|
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.
- By placing this function outside the
define
scope, it's outside the module and therefore won't build correctly. - Given you have created this function, why aren't you using it on
case "datetime" in pattern:
below? You have duplicate block of code.
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, see my comment above (1) and (2) items.
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.
@rxaviers sir,
Sir, there is difference in path used in cldr.main
of blocks of code mentioned. If wanted, we can add a if
block for case "datetime" in pattern:
and check for "datetime" in pattern:
or "skeleton" in pattern:
to handle both in one function. Should I add?
@rxaviers sir, What I have inferred from the issue is this:
Here there is no need to do this since the date and time part can be checked in both A and B ways as mentioned by you above and we won't be requiring individual parts as the 4 cases below don't need them. If they are present individually, they have already been handled before.
Again since we have to return
Here we need to return This is what I meant in the rough code I mentioned here Now I feel I had inferred it wrong. What I now feel needs to be done is this:
Here extract the date and time part by parsing and checking for 'M', 'h' etc.
Check if these exist individually in the
Case 1. If date component has
Okay sir, going through it. |
@rxaviers sir, May I know if new inference is correct or if there is any changes required. |
@rxaviers sir, If there is any change in what I mentioned please let me know or give me a yes. so that I start implementing it. Thank you. Sorry if I am disturbing. |
@manrajgrover, I'm not convinced your interpretation is correct. What pattern do you get for the skeleton |
@rxaviers sir, Nope. But I guess I have started to see your point now and what the algorithm actually says.
We need to take out the date and time from the skeleton provided.
We match the dateSkeleton and timeSkeleton to the
Sir here we will check dateSkeleton and see if it contains
Same here with dateTime raw pattern
Same here with dateTime raw pattern
Same here with dateTime raw pattern Sorry for taking time to understand this. I hope this is correct now. |
Correct. 👍
Correct. 👍
I don't think this is correct. I understood that depending of the fields present in the dateSkeleton or timeSkeleton you should use a different form of "glue". For example, if the skeleton has "MMMM", you must use
No problem. Thanks for the resilience. |
@rxaviers sir, Ohkay sir! I was thinking of giving full flexibility to user to use any I am currently working on it but one thing that is confusing is |
@rxaviers sir, I have re-coded the whole feature and tested on few cases and got positive results. I have also taken care of putting Also please clear the I have not included Please review the code. Thank you. |
@manrajgrover regarding GSoC (I missed your IRC PM), please submit your proposal on the official site, we can review it there. |
@jzaefferer sir, No problem sir. Sure sir. Thank you. :) |
@rxaviers sir, I feel everything is covered now. Please review the code and let me know if I am missing anything. Thank you. |
@@ -29,7 +29,8 @@ function validateRequiredCldr( path, value ) { | |||
skip: [ | |||
/dates\/calendars\/gregorian\/days\/.*\/short/, | |||
/supplemental\/timeData\/(?!001)/, | |||
/supplemental\/weekData\/(?!001)/ | |||
/supplemental\/weekData\/(?!001)/, | |||
/dates\/calendars\/gregorian\/dateTimeFormats\/availableFormats/ |
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.
Style: please sort it using alphabetical order, i.e., as first line.
@rxaviers sir, Made the changes. Please review the fixes. Thank you. |
Hi @rxaviers sir, Please review the code and let me know the changes. Sorry if you're busy and I am disturbing. Thank you. |
@@ -28,6 +28,7 @@ function validateRequiredCldr( path, value ) { | |||
validateCldr( path, value, { | |||
skip: [ | |||
/dates\/calendars\/gregorian\/days\/.*\/short/, | |||
/dates\/calendars\/gregorian\/dateTimeFormats\/availableFormats/, | |||
/supplemental\/timeData\/(?!001)/, | |||
/supplemental\/weekData\/(?!001)/ |
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:
/dates\/calendars\/gregorian\/dateTimeFormats\/availableFormats/,
/dates\/calendars\/gregorian\/days\/.*\/short/,
/supplemental\/timeData\/(?!001)/,
/supplemental\/weekData\/(?!001)/
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.
return function( pattern, cldr ) { | ||
var result; | ||
var result, getDateTime, skeleton, dateSkeleton = "", timeSkeleton = "", type; |
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.
- var result, getDateTime, skeleton, dateSkeleton = "", timeSkeleton = "",
+ var getDateTime, result, skeleton, type,
+ dateSkeleton = "",
+ timeSkeleton = "";
Note that variables that assign initial value are placed in their own lines. Note the alphabetical order.
Implementation is working, great! Now, it's time to fix the coding style issues for which I've left comments inline and consider replacing |
@rxaviers sir, I have replaced |
@manrajgrover, yeap |
Landed thanks |
@rxaviers sir, Great! Thank you for helping me throughout the fix. Really learn't a lot including coding styles through this fix. I feel we should document the new feature now and add examples for the same. |
Sounds good. Feel free to send a PR with such updates. Thanks |
@rxaviers sir,
Please review the code for issue #272 . I have tested it by making changes in
date.js
but not inexpand-pattern.js
. Please let me know the changes.