@contentful/field-editor-date 2.2.3-canary.1 → 2.2.3-canary.2
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.
|
@@ -252,6 +252,15 @@ const _date = require("./date");
|
|
|
252
252
|
(0, _vitest.expect)(result.ampm).toBe('PM');
|
|
253
253
|
(0, _vitest.expect)(result.utcOffset).toBe('+03:00');
|
|
254
254
|
});
|
|
255
|
+
(0, _vitest.it)('normalizes a compact timezone offset for the timezone picker', ()=>{
|
|
256
|
+
const result = (0, _date.userInputFromDatetime)({
|
|
257
|
+
value: '2026-12-11T20:00:00.000-0500',
|
|
258
|
+
uses12hClock: false
|
|
259
|
+
});
|
|
260
|
+
(0, _vitest.expect)(result.time).toBe('20:00');
|
|
261
|
+
(0, _vitest.expect)(result.ampm).toBe('PM');
|
|
262
|
+
(0, _vitest.expect)(result.utcOffset).toBe('-05:00');
|
|
263
|
+
});
|
|
255
264
|
(0, _vitest.it)('parses a full ISO datetime string with 12h clock', ()=>{
|
|
256
265
|
const result = (0, _date.userInputFromDatetime)({
|
|
257
266
|
value: '2018-02-02T05:00+03:00',
|
package/dist/cjs/utils/date.js
CHANGED
|
@@ -30,7 +30,9 @@ function startOfTodayOffset() {
|
|
|
30
30
|
function parseUtcOffset(datetimeString) {
|
|
31
31
|
const match = datetimeString.match(ZONE_RX);
|
|
32
32
|
if (!match) return '+00:00';
|
|
33
|
-
|
|
33
|
+
const utcOffset = match[1];
|
|
34
|
+
if (utcOffset === 'Z') return '+00:00';
|
|
35
|
+
return utcOffset.replace(/^([+-]\d{2})(\d{2})$/, '$1:$2');
|
|
34
36
|
}
|
|
35
37
|
function fieldValueToDate(datetimeString) {
|
|
36
38
|
if (!datetimeString) return null;
|
|
@@ -248,6 +248,15 @@ describe('date utils', ()=>{
|
|
|
248
248
|
expect(result.ampm).toBe('PM');
|
|
249
249
|
expect(result.utcOffset).toBe('+03:00');
|
|
250
250
|
});
|
|
251
|
+
it('normalizes a compact timezone offset for the timezone picker', ()=>{
|
|
252
|
+
const result = userInputFromDatetime({
|
|
253
|
+
value: '2026-12-11T20:00:00.000-0500',
|
|
254
|
+
uses12hClock: false
|
|
255
|
+
});
|
|
256
|
+
expect(result.time).toBe('20:00');
|
|
257
|
+
expect(result.ampm).toBe('PM');
|
|
258
|
+
expect(result.utcOffset).toBe('-05:00');
|
|
259
|
+
});
|
|
251
260
|
it('parses a full ISO datetime string with 12h clock', ()=>{
|
|
252
261
|
const result = userInputFromDatetime({
|
|
253
262
|
value: '2018-02-02T05:00+03:00',
|
package/dist/esm/utils/date.js
CHANGED
|
@@ -6,7 +6,9 @@ function startOfTodayOffset() {
|
|
|
6
6
|
function parseUtcOffset(datetimeString) {
|
|
7
7
|
const match = datetimeString.match(ZONE_RX);
|
|
8
8
|
if (!match) return '+00:00';
|
|
9
|
-
|
|
9
|
+
const utcOffset = match[1];
|
|
10
|
+
if (utcOffset === 'Z') return '+00:00';
|
|
11
|
+
return utcOffset.replace(/^([+-]\d{2})(\d{2})$/, '$1:$2');
|
|
10
12
|
}
|
|
11
13
|
function fieldValueToDate(datetimeString) {
|
|
12
14
|
if (!datetimeString) return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-date",
|
|
3
|
-
"version": "2.2.3-canary.
|
|
3
|
+
"version": "2.2.3-canary.2+dd576628",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"registry": "https://npm.pkg.github.com/"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "dd576628ac588a292442c2668320d74e6dda680a"
|
|
62
62
|
}
|