Skip to content

Commit

Permalink
Add upper/lower presentation format for am/pm in fromMillis
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Woodgate <[email protected]>
  • Loading branch information
Alex Woodgate authored and mattbaileyuk committed Aug 10, 2023
1 parent 3f357ec commit 7a7f2b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 7a7f2b5

Please sign in to comment.