Skip to content

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

Merged
merged 25 commits into from
Apr 1, 2024

Conversation

sven-oly
Copy link
Collaborator

No description provided.

@sven-oly sven-oly changed the title Start date time in CPP Add date/time and list format test data via Node. Test these in NodeJS. Mar 22, 2024
@sven-oly
Copy link
Collaborator Author

Please take a look. Note that CPP datetime instances all fail now, and CPP doesn't have list format.

@sven-oly sven-oly changed the title Add date/time and list format test data via Node. Test these in NodeJS. Add date/time, list format, relative date/time data. Some executors added in NodeJS and ICU4X. Mar 26, 2024

string era_str;
string year_str;
string month_str;
Copy link
Member

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?

Copy link
Collaborator Author

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.

Comment on lines 208 to 212
// 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 {
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

Comment on lines 220 to 224
UnicodeString parse_skeleton = "YYYY-MM-DD HH:mm:ss";

DateFormat* dparser = DateFormat::createInstanceForSkeleton(parse_skeleton,
displayLocale,
status);
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this!

Comment on lines 15 to 17
const locales = ['und',
'en-US', 'zh-TW', 'pt', 'vi', 'el', 'mt-MT', 'ru', 'en-GB',
'bn', 'ar','mr', 'zu'];
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Added!

Copy link
Collaborator

@echeran echeran left a 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

// 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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cout << "# Skelecton = " << skeleton_string << endl;
cout << "# Skeleton = " << skeleton_string << endl;


cout << "# Skelecton = " << skeleton_string << endl;

UnicodeString u_skeleton = skeleton_string.c_str();
Copy link
Collaborator

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.)

Copy link
Collaborator Author

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.

@sven-oly
Copy link
Collaborator Author

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.

@sven-oly
Copy link
Collaborator Author

sven-oly commented Apr 1, 2024

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.

Comment on lines 27 to 38
"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"
},
Copy link
Member

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?

Copy link
Collaborator Author

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.

"description": "version of conformance data",
"type": "string"
},
"test_ environmment": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space character?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed!

@sven-oly sven-oly merged commit 75b477e into unicode-org:main Apr 1, 2024
@sven-oly sven-oly deleted the startDateTime branch April 1, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants