@contentful/field-editor-date 2.2.3-canary.1 → 2.2.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.
@@ -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',
@@ -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
- return match[1] === 'Z' ? '+00:00' : match[1];
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',
@@ -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
- return match[1] === 'Z' ? '+00:00' : match[1];
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.1+b2a2eedc",
3
+ "version": "2.2.3",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "date-fns": "^2.30.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/core": "^7.29.7",
47
+ "@babel/core": "^7.7.4",
48
48
  "@contentful/field-editor-test-utils": "^3.1.2",
49
49
  "@lingui/core": "5.3.0",
50
50
  "@types/timezoned-date": "^3.0.0",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://npm.pkg.github.com/"
60
60
  },
61
- "gitHead": "b2a2eedc50ce211755a7aa51666706ac3a48acee"
61
+ "gitHead": "368c791952bff68af50417090b4ff3f00e5f50ed"
62
62
  }