-
-
Notifications
You must be signed in to change notification settings - Fork 13
Add date/time, list format, relative date/time data. Some executors added in NodeJS and ICU4X. #183
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
Conversation
Please take a look. Note that CPP datetime instances all fail now, and CPP doesn't have list format. |
executors/cpp/datetime_fmt.cpp
Outdated
|
||
string era_str; | ||
string year_str; | ||
string month_str; |
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.
Question: I don't see where you read these variables. Intentional?
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.
They will be used when I figure out the API to handle individual fields in CPP version of DateTime format.
executors/cpp/datetime_fmt.cpp
Outdated
// Prefer milliseconds as input. | ||
json_object *input_millis = json_object_object_get(json_in, "input_millis"); | ||
if (input_millis) { | ||
testDateTime = json_object_get_double(input_millis); | ||
} else { |
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 bit messy; you should either have the timestamp or the ISO string but having both just creates confusion. I prefer the ISO string because it is less ambiguous.
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.
OK, I'm removing the milliseconds as an output field.
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.
Reversal - parsing the date isn't yet working, so I'm keeping the milliseconds for now.
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 chat about how to use absl
here, which I think is the right thing to do.
executors/cpp/datetime_fmt.cpp
Outdated
UnicodeString parse_skeleton = "YYYY-MM-DD HH:mm:ss"; | ||
|
||
DateFormat* dparser = DateFormat::createInstanceForSkeleton(parse_skeleton, | ||
displayLocale, | ||
status); |
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.
You shouldn't use an ICU4C DateFormat to parse an ISO-8601 string. You should be able to parse it directly or using a helper library such as absl
.
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.
Good idea! I'll add this.
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.
Parsing date string isn't yet working.
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.
Fixed this!
testgen/generators/list_fmt_gen.js
Outdated
const locales = ['und', | ||
'en-US', 'zh-TW', 'pt', 'vi', 'el', 'mt-MT', 'ru', 'en-GB', | ||
'bn', 'ar','mr', 'zu']; |
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.
Suggestion: include Spanish, which uses inflection to pick between o
and u
and between y
and e
, and make sure there is a test that exercises this code path.
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.
Good idea! Added!
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.
initial comments. will continue
executors/cpp/datetime_fmt.cpp
Outdated
// Data specifies a date time skeleton. Make a formatter based on this. | ||
string skeleton_string = json_object_get_string(date_skeleton_obj); | ||
|
||
cout << "# Skelecton = " << skeleton_string << endl; |
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.
cout << "# Skelecton = " << skeleton_string << endl; | |
cout << "# Skeleton = " << skeleton_string << endl; |
executors/cpp/datetime_fmt.cpp
Outdated
|
||
cout << "# Skelecton = " << skeleton_string << endl; | ||
|
||
UnicodeString u_skeleton = skeleton_string.c_str(); |
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.
Apparently, this isn't the way to convert C String -> UnicodeString. You should use this UnicodeString constructor, and only if the text is ASCII. If the char *
text is not ASCII, then you need to do a codepage conversion first before converting to UnicodeString.
(I asked Shane b/c I didn't see any char *
arg operator=()
for UnicodeString. He learned the above info from Markus, so you can double check with him to make sure that's correct.)
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. Constructor is now in place.
OK, this is moving along. I've got a form of skeletons (not debugged) for use in ICU4C. However, it's not yet using Calendar or Timezone, so most cases still fail. |
PTAL. Note that Date Time formatting still has substantial test failure due to calendar not handled correctly. New test data generator uses Node's formatToParts to get test data that is compatible with ICU4J/C with NBSP. |
schema/datetime_fmt/test_schema.json
Outdated
"input": { | ||
"description": "date time specification in XYZ format", | ||
"type": "string" | ||
}, | ||
"input_millis": { | ||
"description": "numeric value for time in milliseconds since January 1, 1970, UTC (the epoch)", | ||
"type": "string" | ||
}, | ||
"input_string": { | ||
"description": "String in ISO 8601 form, e.g. YYYY-MM-DD hh:mm:ss.sss", | ||
"type": "string" | ||
}, |
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.
Are all three of these fields valid input?
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.
Removed input and input_millis fields.
schema/list_fmt/test_schema.json
Outdated
"description": "version of conformance data", | ||
"type": "string" | ||
}, | ||
"test_ environmment": { |
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.
Extra space character?
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.
Good catch! Fixed!
No description provided.