@brightspace-ui/intl 3.48.4 → 3.48.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dateTime.js +16 -3
- package/package.json +1 -1
package/lib/dateTime.js
CHANGED
|
@@ -643,6 +643,19 @@ export function convertLocalToUTCDateTime(date) {
|
|
|
643
643
|
};
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
function convertLocalDateToInstant(date) {
|
|
647
|
+
if (!getDocumentLocaleSettings().timezone.identifier) return date;
|
|
648
|
+
const utc = convertLocalToUTCDateTime({
|
|
649
|
+
year: date.getFullYear(),
|
|
650
|
+
month: date.getMonth() + 1,
|
|
651
|
+
date: date.getDate(),
|
|
652
|
+
hours: date.getHours(),
|
|
653
|
+
minutes: date.getMinutes(),
|
|
654
|
+
seconds: date.getSeconds()
|
|
655
|
+
});
|
|
656
|
+
return new Date(Date.UTC(utc.year, utc.month - 1, utc.date, utc.hours, utc.minutes, utc.seconds));
|
|
657
|
+
}
|
|
658
|
+
|
|
646
659
|
export function convertUTCToLocalDateTime(date) {
|
|
647
660
|
if (!getDocumentLocaleSettings().timezone.identifier) {
|
|
648
661
|
return date;
|
|
@@ -872,7 +885,7 @@ export function getDateTimeDescriptor() {
|
|
|
872
885
|
|
|
873
886
|
export function formatTime(date, options = {}) {
|
|
874
887
|
|
|
875
|
-
if (options.skeleton) return formatDateTimeSkeleton(date, options, { date: false });
|
|
888
|
+
if (options.skeleton) return formatDateTimeSkeleton(convertLocalDateToInstant(date), options, { date: false });
|
|
876
889
|
|
|
877
890
|
const descriptor = getDateTimeDescriptor();
|
|
878
891
|
const settings = getDocumentLocaleSettings();
|
|
@@ -970,7 +983,7 @@ export function parseTime(input, options) {
|
|
|
970
983
|
|
|
971
984
|
export function formatDate(date, options = {}) {
|
|
972
985
|
|
|
973
|
-
if (options.skeleton) return formatDateTimeSkeleton(date, options, { time: false });
|
|
986
|
+
if (options.skeleton) return formatDateTimeSkeleton(convertLocalDateToInstant(date), options, { time: false });
|
|
974
987
|
|
|
975
988
|
const descriptor = getDateTimeDescriptor();
|
|
976
989
|
|
|
@@ -1054,7 +1067,7 @@ export function parseDate(input) {
|
|
|
1054
1067
|
|
|
1055
1068
|
export function formatDateTime(date, options = {}) {
|
|
1056
1069
|
|
|
1057
|
-
if (options.skeleton) return formatDateTimeSkeleton(date, options);
|
|
1070
|
+
if (options.skeleton) return formatDateTimeSkeleton(convertLocalDateToInstant(date), options);
|
|
1058
1071
|
|
|
1059
1072
|
const format = options.format || 'short';
|
|
1060
1073
|
|
package/package.json
CHANGED