Skip to content

Commit 7a7f2b5

Browse files
Alex Woodgatemattbaileyuk
Alex Woodgate
authored andcommittedAug 10, 2023
Add upper/lower presentation format for am/pm in fromMillis
Signed-off-by: Alex Woodgate <[email protected]>
1 parent 3f357ec commit 7a7f2b5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎src/datetime.js

+7
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,13 @@ const dateTime = (function () {
904904
if (offset === 0 && markerSpec.presentation2 === 't') {
905905
componentValue = 'Z';
906906
}
907+
} else if (markerSpec.component === 'P') {
908+
// §9.8.4.7 Formatting Other Components
909+
// Formatting P for am/pm
910+
// getDateTimeFragment() always returns am/pm lower case so check for UPPER here
911+
if (markerSpec.names === tcase.UPPER) {
912+
componentValue = componentValue.toUpperCase();
913+
}
907914
}
908915
return componentValue;
909916
};

‎test/test-suite/groups/function-fromMillis/formatDateTime.json

+16
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,22 @@
539539
"2018-10-21T13:05:00.000Z"
540540
]
541541
},
542+
{
543+
"function": "#fromMillis",
544+
"category": "Upper case AM/PM presentation",
545+
"description": "am/pm presentation should be set to uppercase AM",
546+
"expr": "$fromMillis(1521801216617, '[F], [D]/[M]/[Y] [h]:[m]:[s] [PN]')",
547+
"data": {},
548+
"result": "friday, 23/3/2018 10:33:36 AM"
549+
},
550+
{
551+
"function": "#fromMillis",
552+
"category": "Lower case AM/PM presentation",
553+
"description": "am/pm presentation should be set to lowercase am",
554+
"expr": "$fromMillis(1521801216617, '[F], [D]/[M]/[Y] [h]:[m]:[s] [Pn]')",
555+
"data": {},
556+
"result": "friday, 23/3/2018 10:33:36 am"
557+
},
542558
{
543559
"function": "#fromMillis",
544560
"category": "error",

0 commit comments

Comments
 (0)
Please sign in to comment.