@abp/luxon 9.2.0-rc.1 → 9.2.0-rc.3
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/package.json +2 -2
- package/src/abp.luxon.js +57 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "9.2.0-rc.
|
|
2
|
+
"version": "9.2.0-rc.3",
|
|
3
3
|
"name": "@abp/luxon",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@abp/core": "~9.2.0-rc.
|
|
13
|
+
"@abp/core": "~9.2.0-rc.3",
|
|
14
14
|
"luxon": "^3.5.0"
|
|
15
15
|
},
|
|
16
16
|
"gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431",
|
package/src/abp.luxon.js
CHANGED
|
@@ -32,7 +32,7 @@ var abp = abp || {};
|
|
|
32
32
|
.fromFormat(
|
|
33
33
|
getObjectValue(form, field),
|
|
34
34
|
abp.localization.currentCulture.dateTimeFormat.shortDatePattern,
|
|
35
|
-
{locale: abp.localization.currentCulture.cultureName}
|
|
35
|
+
{ locale: abp.localization.currentCulture.cultureName }
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
if (!dateTime.invalid) {
|
|
@@ -43,4 +43,60 @@ var abp = abp || {};
|
|
|
43
43
|
return form;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// Normalize Date object or date string to standard string format that will be sent to server
|
|
47
|
+
abp.clock.normalizeToString = function (date) {
|
|
48
|
+
if (!date) {
|
|
49
|
+
return date;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var dateObj = date instanceof Date ? date : new Date(date);
|
|
53
|
+
if (isNaN(dateObj)) {
|
|
54
|
+
return date;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var timeZone = abp.clock.timeZone();
|
|
58
|
+
if (abp.clock.supportsMultipleTimezone() && timeZone) {
|
|
59
|
+
return luxon.DateTime.fromObject({
|
|
60
|
+
year: dateObj.getFullYear(),
|
|
61
|
+
month: dateObj.getMonth() + 1,
|
|
62
|
+
day: dateObj.getDate(),
|
|
63
|
+
hour: dateObj.getHours(),
|
|
64
|
+
minute: dateObj.getMinutes(),
|
|
65
|
+
second: dateObj.getSeconds()
|
|
66
|
+
}, { zone: timeZone }).setZone("utc").toISO();
|
|
67
|
+
} else {
|
|
68
|
+
return luxon.DateTime.fromJSDate(dateObj).toFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Normalize date string to locale date string that will be displayed to user
|
|
73
|
+
abp.clock.normalizeToLocaleString = function (dateString, options) {
|
|
74
|
+
if (!dateString) {
|
|
75
|
+
return dateString;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var date = new Date(dateString);
|
|
79
|
+
if (isNaN(date)) {
|
|
80
|
+
return dateString;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
options = options || abp.clock.toLocaleStringOptions;
|
|
84
|
+
if (abp.clock.supportsMultipleTimezone()) {
|
|
85
|
+
var timezone = abp.clock.timeZone();
|
|
86
|
+
if (timezone) {
|
|
87
|
+
return luxon.DateTime.fromJSDate(date)
|
|
88
|
+
.setZone(timezone)
|
|
89
|
+
.setLocale(abp.localization.currentCulture.cultureName)
|
|
90
|
+
.toLocaleString(options);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return luxon.DateTime.fromJSDate(date)
|
|
95
|
+
.setLocale(abp.localization.currentCulture.cultureName)
|
|
96
|
+
.toLocaleString(options);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
abp.clock.browserTimeZone = function () {
|
|
100
|
+
return luxon.DateTime.local().zoneName;
|
|
101
|
+
}
|
|
46
102
|
})(jQuery);
|