Skip to content
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

Add upper/lower presentation format for am/pm in fromMillis #644

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ const dateTime = (function () {
if (offset === 0 && markerSpec.presentation2 === 't') {
componentValue = 'Z';
}
} else if (markerSpec.component === 'P') {
// §9.8.4.7 Formatting Other Components
// Formatting P for am/pm
// getDateTimeFragment() always returns am/pm lower case so check for UPPER here
if (markerSpec.names === tcase.UPPER) {
componentValue = componentValue.toUpperCase();
}
}
return componentValue;
};
Expand Down
16 changes: 16 additions & 0 deletions test/test-suite/groups/function-fromMillis/formatDateTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@
"2018-10-21T13:05:00.000Z"
]
},
{
"function": "#fromMillis",
"category": "Upper case AM/PM presentation",
"description": "am/pm presentation should be set to uppercase AM",
"expr": "$fromMillis(1521801216617, '[F], [D]/[M]/[Y] [h]:[m]:[s] [PN]')",
"data": {},
"result": "friday, 23/3/2018 10:33:36 AM"
},
{
"function": "#fromMillis",
"category": "Lower case AM/PM presentation",
"description": "am/pm presentation should be set to lowercase am",
"expr": "$fromMillis(1521801216617, '[F], [D]/[M]/[Y] [h]:[m]:[s] [Pn]')",
"data": {},
"result": "friday, 23/3/2018 10:33:36 am"
},
{
"function": "#fromMillis",
"category": "error",
Expand Down