@operato/data-grist 10.29.2 → 10.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/data-grist",
3
- "version": "10.29.2",
3
+ "version": "10.29.5",
4
4
  "description": "User interface for grid (desktop) and list (mobile)",
5
5
  "author": "heartyoh",
6
6
  "type": "module",
@@ -72,7 +72,7 @@
72
72
  "@operato/i18n": "^10.29.1",
73
73
  "@operato/input": "^10.29.1",
74
74
  "@operato/list-state": "^10.29.1",
75
- "@operato/p13n": "^10.29.2",
75
+ "@operato/p13n": "^10.29.5",
76
76
  "@operato/popup": "^10.29.1",
77
77
  "@operato/pull-to-refresh": "^10.29.1",
78
78
  "@operato/styles": "^10.29.1",
@@ -116,5 +116,5 @@
116
116
  "prettier --write"
117
117
  ]
118
118
  },
119
- "gitHead": "492e81b3185946b008e3dec3b69b575d7f9e6f35"
119
+ "gitHead": "0995f71d6a9678da116781ec38ae80a253ab8b3e"
120
120
  }
@@ -0,0 +1,55 @@
1
+ import { expect } from '@open-wc/testing'
2
+ import { render } from 'lit'
3
+
4
+ import { OxGristRendererDate } from '../src/renderers/ox-grist-renderer-date.js'
5
+
6
+ /**
7
+ * 'YYYY-MM-DD' 는 달력의 날이다. 브라우저가 UTC 서쪽에 있어도 그 날 그대로 나와야 한다.
8
+ *
9
+ * 시험 브라우저의 시간대는 고를 수 없으므로, 시간대를 적지 않은 Intl.DateTimeFormat 을 America/Tijuana
10
+ * 로 돌린다 — 그 시간대의 브라우저가 날짜를 적는 길과 같다.
11
+ */
12
+ const WEST = 'America/Tijuana'
13
+
14
+ function renderText(value: any, type: string): string {
15
+ const column = { type, record: {} } as any
16
+ const host = document.createElement('div')
17
+ render(OxGristRendererDate(value, column, {}, 0, undefined as any) as any, host)
18
+ return host.textContent!.trim()
19
+ }
20
+
21
+ describe('OxGristRendererDate — calendar day', () => {
22
+ const Original = Intl.DateTimeFormat
23
+
24
+ beforeEach(() => {
25
+ ;(Intl as any).DateTimeFormat = function (locales?: any, options: any = {}) {
26
+ return new Original(locales, { timeZone: WEST, ...options })
27
+ }
28
+ })
29
+
30
+ afterEach(() => {
31
+ ;(Intl as any).DateTimeFormat = Original
32
+ })
33
+
34
+ it("renders '2025-12-31' as Dec 31 west of UTC", () => {
35
+ const expected = new Original(undefined, { year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'UTC' }).format(
36
+ Date.UTC(2025, 11, 31)
37
+ )
38
+ expect(renderText('2025-12-31', 'date')).to.equal(expected)
39
+ })
40
+
41
+ it('still renders a datetime instant in the browser time zone', () => {
42
+ // 2025-12-31T03:00Z is Dec 30 evening in Tijuana.
43
+ const text = renderText('2025-12-31T03:00:00Z', 'datetime')
44
+ const expected = new Original(undefined, {
45
+ year: 'numeric',
46
+ month: 'numeric',
47
+ day: 'numeric',
48
+ hour: 'numeric',
49
+ minute: '2-digit',
50
+ hour12: false,
51
+ timeZone: WEST
52
+ }).format(new Date('2025-12-31T03:00:00Z'))
53
+ expect(text).to.equal(expected)
54
+ })
55
+ })