@simplysm/core-common 13.0.0-beta.2 → 13.0.0-beta.21
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/dist/common.types.js +4 -4
- package/dist/errors/argument-error.js +1 -1
- package/dist/errors/not-implemented-error.js +1 -1
- package/dist/errors/timeout-error.js +1 -1
- package/dist/extensions/arr-ext.helpers.js +4 -4
- package/dist/extensions/arr-ext.js +9 -9
- package/dist/features/debounce-queue.js +2 -2
- package/dist/features/serial-queue.js +3 -3
- package/dist/index.js +30 -30
- package/dist/types/date-only.js +2 -2
- package/dist/types/date-time.js +2 -2
- package/dist/types/time.js +2 -2
- package/dist/types/uuid.js +1 -1
- package/dist/utils/bytes.js +1 -1
- package/dist/utils/json.js +8 -8
- package/dist/utils/obj.js +5 -5
- package/dist/utils/primitive.js +5 -5
- package/dist/utils/transferable.js +4 -4
- package/dist/utils/wait.js +1 -1
- package/package.json +7 -4
- package/.cache/typecheck-browser.tsbuildinfo +0 -1
- package/.cache/typecheck-node.tsbuildinfo +0 -1
- package/.cache/typecheck-tests-browser.tsbuildinfo +0 -1
- package/.cache/typecheck-tests-node.tsbuildinfo +0 -1
- package/src/common.types.ts +0 -91
- package/src/env.ts +0 -11
- package/src/errors/argument-error.ts +0 -40
- package/src/errors/not-implemented-error.ts +0 -32
- package/src/errors/sd-error.ts +0 -53
- package/src/errors/timeout-error.ts +0 -36
- package/src/extensions/arr-ext.helpers.ts +0 -53
- package/src/extensions/arr-ext.ts +0 -777
- package/src/extensions/arr-ext.types.ts +0 -258
- package/src/extensions/map-ext.ts +0 -86
- package/src/extensions/set-ext.ts +0 -68
- package/src/features/debounce-queue.ts +0 -116
- package/src/features/event-emitter.ts +0 -112
- package/src/features/serial-queue.ts +0 -94
- package/src/globals.ts +0 -12
- package/src/index.ts +0 -55
- package/src/types/date-only.ts +0 -329
- package/src/types/date-time.ts +0 -294
- package/src/types/lazy-gc-map.ts +0 -244
- package/src/types/time.ts +0 -210
- package/src/types/uuid.ts +0 -113
- package/src/utils/bytes.ts +0 -160
- package/src/utils/date-format.ts +0 -239
- package/src/utils/json.ts +0 -230
- package/src/utils/num.ts +0 -97
- package/src/utils/obj.ts +0 -956
- package/src/utils/path.ts +0 -40
- package/src/utils/primitive.ts +0 -33
- package/src/utils/str.ts +0 -252
- package/src/utils/template-strings.ts +0 -132
- package/src/utils/transferable.ts +0 -269
- package/src/utils/wait.ts +0 -40
- package/src/utils/xml.ts +0 -105
- package/src/zip/sd-zip.ts +0 -218
- package/tests/errors/errors.spec.ts +0 -196
- package/tests/extensions/array-extension.spec.ts +0 -790
- package/tests/extensions/map-extension.spec.ts +0 -147
- package/tests/extensions/set-extension.spec.ts +0 -74
- package/tests/types/date-only.spec.ts +0 -636
- package/tests/types/date-time.spec.ts +0 -391
- package/tests/types/lazy-gc-map.spec.ts +0 -692
- package/tests/types/time.spec.ts +0 -559
- package/tests/types/types.spec.ts +0 -55
- package/tests/types/uuid.spec.ts +0 -91
- package/tests/utils/bytes-utils.spec.ts +0 -230
- package/tests/utils/date-format.spec.ts +0 -371
- package/tests/utils/debounce-queue.spec.ts +0 -272
- package/tests/utils/json.spec.ts +0 -475
- package/tests/utils/number.spec.ts +0 -184
- package/tests/utils/object.spec.ts +0 -827
- package/tests/utils/path.spec.ts +0 -78
- package/tests/utils/primitive.spec.ts +0 -55
- package/tests/utils/sd-event-emitter.spec.ts +0 -216
- package/tests/utils/serial-queue.spec.ts +0 -365
- package/tests/utils/string.spec.ts +0 -294
- package/tests/utils/template-strings.spec.ts +0 -96
- package/tests/utils/transferable.spec.ts +0 -698
- package/tests/utils/wait.spec.ts +0 -145
- package/tests/utils/xml.spec.ts +0 -146
- package/tests/zip/sd-zip.spec.ts +0 -234
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { DateTime } from "@simplysm/core-common";
|
|
3
|
-
|
|
4
|
-
describe("DateTime", () => {
|
|
5
|
-
describe("constructor", () => {
|
|
6
|
-
it("기본 생성자는 현재 시간을 사용한다", () => {
|
|
7
|
-
const before = Date.now();
|
|
8
|
-
const dt = new DateTime();
|
|
9
|
-
const after = Date.now();
|
|
10
|
-
|
|
11
|
-
expect(dt.tick).toBeGreaterThanOrEqual(before);
|
|
12
|
-
expect(dt.tick).toBeLessThanOrEqual(after);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("년월일시분초밀리초로 생성한다", () => {
|
|
16
|
-
const dt = new DateTime(2024, 3, 15, 10, 30, 45, 123);
|
|
17
|
-
|
|
18
|
-
expect(dt.year).toBe(2024);
|
|
19
|
-
expect(dt.month).toBe(3);
|
|
20
|
-
expect(dt.day).toBe(15);
|
|
21
|
-
expect(dt.hour).toBe(10);
|
|
22
|
-
expect(dt.minute).toBe(30);
|
|
23
|
-
expect(dt.second).toBe(45);
|
|
24
|
-
expect(dt.millisecond).toBe(123);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("tick으로 생성한다", () => {
|
|
28
|
-
const tick = 1710489045123;
|
|
29
|
-
const dt = new DateTime(tick);
|
|
30
|
-
|
|
31
|
-
expect(dt.tick).toBe(tick);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("Date 객체로 생성한다", () => {
|
|
35
|
-
const date = new Date(2024, 2, 15, 10, 30, 45, 123);
|
|
36
|
-
const dt = new DateTime(date);
|
|
37
|
-
|
|
38
|
-
expect(dt.year).toBe(2024);
|
|
39
|
-
expect(dt.month).toBe(3);
|
|
40
|
-
expect(dt.day).toBe(15);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("윤년 2월 29일을 생성한다", () => {
|
|
44
|
-
const dt = new DateTime(2024, 2, 29);
|
|
45
|
-
|
|
46
|
-
expect(dt.year).toBe(2024);
|
|
47
|
-
expect(dt.month).toBe(2);
|
|
48
|
-
expect(dt.day).toBe(29);
|
|
49
|
-
expect(dt.isValid).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("평년 2월 29일은 3월 1일로 자동 조정된다 (JS Date 동작)", () => {
|
|
53
|
-
const dt = new DateTime(2023, 2, 29);
|
|
54
|
-
|
|
55
|
-
expect(dt.year).toBe(2023);
|
|
56
|
-
expect(dt.month).toBe(3);
|
|
57
|
-
expect(dt.day).toBe(1);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("유효하지 않은 월(13월)은 다음 해 1월로 자동 조정된다 (JS Date 동작)", () => {
|
|
61
|
-
const dt = new DateTime(2024, 13, 1);
|
|
62
|
-
|
|
63
|
-
expect(dt.year).toBe(2025);
|
|
64
|
-
expect(dt.month).toBe(1);
|
|
65
|
-
expect(dt.day).toBe(1);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("parse()", () => {
|
|
70
|
-
it("ISO 8601 형식을 파싱한다", () => {
|
|
71
|
-
const dt = DateTime.parse("2024-03-15T10:30:45.123Z");
|
|
72
|
-
|
|
73
|
-
expect(dt.year).toBe(2024);
|
|
74
|
-
expect(dt.month).toBe(3);
|
|
75
|
-
expect(dt.day).toBe(15);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("yyyy-MM-dd HH:mm:ss 형식을 파싱한다", () => {
|
|
79
|
-
const dt = DateTime.parse("2024-03-15 10:30:45");
|
|
80
|
-
|
|
81
|
-
expect(dt.year).toBe(2024);
|
|
82
|
-
expect(dt.month).toBe(3);
|
|
83
|
-
expect(dt.day).toBe(15);
|
|
84
|
-
expect(dt.hour).toBe(10);
|
|
85
|
-
expect(dt.minute).toBe(30);
|
|
86
|
-
expect(dt.second).toBe(45);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("밀리초 포함 형식을 파싱한다", () => {
|
|
90
|
-
const dt = DateTime.parse("2024-03-15 10:30:45.123");
|
|
91
|
-
|
|
92
|
-
expect(dt.millisecond).toBe(123);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("밀리초 1자리는 100ms 단위로 패딩한다 (ISO 8601)", () => {
|
|
96
|
-
const dt = DateTime.parse("2024-03-15 10:30:45.1");
|
|
97
|
-
|
|
98
|
-
expect(dt.millisecond).toBe(100);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("밀리초 2자리는 10ms 단위로 패딩한다 (ISO 8601)", () => {
|
|
102
|
-
const dt = DateTime.parse("2024-03-15 10:30:45.01");
|
|
103
|
-
|
|
104
|
-
expect(dt.millisecond).toBe(10);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("밀리초 3자리는 그대로 파싱한다", () => {
|
|
108
|
-
const dt = DateTime.parse("2024-03-15 10:30:45.001");
|
|
109
|
-
|
|
110
|
-
expect(dt.millisecond).toBe(1);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("yyyyMMddHHmmss 형식을 파싱한다", () => {
|
|
114
|
-
const dt = DateTime.parse("20240315103045");
|
|
115
|
-
|
|
116
|
-
expect(dt.year).toBe(2024);
|
|
117
|
-
expect(dt.month).toBe(3);
|
|
118
|
-
expect(dt.day).toBe(15);
|
|
119
|
-
expect(dt.hour).toBe(10);
|
|
120
|
-
expect(dt.minute).toBe(30);
|
|
121
|
-
expect(dt.second).toBe(45);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("오전/오후 형식을 파싱한다", () => {
|
|
125
|
-
const dtAm = DateTime.parse("2024-03-15 오전 10:30:45");
|
|
126
|
-
expect(dtAm.hour).toBe(10);
|
|
127
|
-
|
|
128
|
-
const dtPm = DateTime.parse("2024-03-15 오후 02:30:45");
|
|
129
|
-
expect(dtPm.hour).toBe(14);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("오후 12:00:00은 정오(12시)", () => {
|
|
133
|
-
const dt = DateTime.parse("2024-03-15 오후 12:00:00");
|
|
134
|
-
|
|
135
|
-
expect(dt.hour).toBe(12);
|
|
136
|
-
expect(dt.minute).toBe(0);
|
|
137
|
-
expect(dt.second).toBe(0);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("오전 12:00:00은 자정(0시)", () => {
|
|
141
|
-
const dt = DateTime.parse("2024-03-15 오전 12:00:00");
|
|
142
|
-
|
|
143
|
-
expect(dt.hour).toBe(0);
|
|
144
|
-
expect(dt.minute).toBe(0);
|
|
145
|
-
expect(dt.second).toBe(0);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("오후 12:30:45는 정오 이후(12시 30분 45초)", () => {
|
|
149
|
-
const dt = DateTime.parse("2024-03-15 오후 12:30:45");
|
|
150
|
-
|
|
151
|
-
expect(dt.hour).toBe(12);
|
|
152
|
-
expect(dt.minute).toBe(30);
|
|
153
|
-
expect(dt.second).toBe(45);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("오전 12:30:45는 자정 이후(0시 30분 45초)", () => {
|
|
157
|
-
const dt = DateTime.parse("2024-03-15 오전 12:30:45");
|
|
158
|
-
|
|
159
|
-
expect(dt.hour).toBe(0);
|
|
160
|
-
expect(dt.minute).toBe(30);
|
|
161
|
-
expect(dt.second).toBe(45);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("잘못된 형식은 에러를 던진다", () => {
|
|
165
|
-
expect(() => DateTime.parse("invalid")).toThrow();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe("불변성", () => {
|
|
170
|
-
it("setYear는 새 인스턴스를 반환한다", () => {
|
|
171
|
-
const dt1 = new DateTime(2024, 3, 15);
|
|
172
|
-
const dt2 = dt1.setYear(2025);
|
|
173
|
-
|
|
174
|
-
expect(dt1.year).toBe(2024);
|
|
175
|
-
expect(dt2.year).toBe(2025);
|
|
176
|
-
expect(dt1).not.toBe(dt2);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("setMonth는 새 인스턴스를 반환한다", () => {
|
|
180
|
-
const dt1 = new DateTime(2024, 3, 15);
|
|
181
|
-
const dt2 = dt1.setMonth(6);
|
|
182
|
-
|
|
183
|
-
expect(dt1.month).toBe(3);
|
|
184
|
-
expect(dt2.month).toBe(6);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("setMonth는 마지막 날짜를 조정한다", () => {
|
|
188
|
-
// 1월 31일 → 2월 (28일 또는 29일로 조정)
|
|
189
|
-
const dt1 = new DateTime(2024, 1, 31);
|
|
190
|
-
const dt2 = dt1.setMonth(2);
|
|
191
|
-
|
|
192
|
-
expect(dt2.month).toBe(2);
|
|
193
|
-
expect(dt2.day).toBe(29); // 2024는 윤년
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("setMonth(13)은 다음 해 1월을 반환한다", () => {
|
|
197
|
-
const dt = new DateTime(2024, 6, 15);
|
|
198
|
-
const result = dt.setMonth(13);
|
|
199
|
-
|
|
200
|
-
expect(result.year).toBe(2025);
|
|
201
|
-
expect(result.month).toBe(1);
|
|
202
|
-
expect(result.day).toBe(15);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("setMonth(0)은 이전 해 12월을 반환한다", () => {
|
|
206
|
-
const dt = new DateTime(2024, 6, 15);
|
|
207
|
-
const result = dt.setMonth(0);
|
|
208
|
-
|
|
209
|
-
expect(result.year).toBe(2023);
|
|
210
|
-
expect(result.month).toBe(12);
|
|
211
|
-
expect(result.day).toBe(15);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("setMonth(-1)은 이전 해 11월을 반환한다", () => {
|
|
215
|
-
const dt = new DateTime(2024, 6, 15);
|
|
216
|
-
const result = dt.setMonth(-1);
|
|
217
|
-
|
|
218
|
-
expect(result.year).toBe(2023);
|
|
219
|
-
expect(result.month).toBe(11);
|
|
220
|
-
expect(result.day).toBe(15);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it("setMonth(25)는 2년 후 1월을 반환한다", () => {
|
|
224
|
-
const dt = new DateTime(2024, 6, 15);
|
|
225
|
-
const result = dt.setMonth(25);
|
|
226
|
-
|
|
227
|
-
expect(result.year).toBe(2026);
|
|
228
|
-
expect(result.month).toBe(1);
|
|
229
|
-
expect(result.day).toBe(15);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it("setMonth(-13)은 2년 전 11월을 반환한다", () => {
|
|
233
|
-
const dt = new DateTime(2024, 6, 15);
|
|
234
|
-
const result = dt.setMonth(-13);
|
|
235
|
-
|
|
236
|
-
expect(result.year).toBe(2022);
|
|
237
|
-
expect(result.month).toBe(11);
|
|
238
|
-
expect(result.day).toBe(15);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe("산술 메서드", () => {
|
|
243
|
-
it("addYears", () => {
|
|
244
|
-
const dt1 = new DateTime(2024, 3, 15);
|
|
245
|
-
const dt2 = dt1.addYears(2);
|
|
246
|
-
|
|
247
|
-
expect(dt2.year).toBe(2026);
|
|
248
|
-
expect(dt1.year).toBe(2024); // 원본 불변
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("addMonths", () => {
|
|
252
|
-
const dt1 = new DateTime(2024, 3, 15);
|
|
253
|
-
const dt2 = dt1.addMonths(3);
|
|
254
|
-
|
|
255
|
-
expect(dt2.month).toBe(6);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("addDays", () => {
|
|
259
|
-
const dt1 = new DateTime(2024, 3, 15);
|
|
260
|
-
const dt2 = dt1.addDays(20);
|
|
261
|
-
|
|
262
|
-
expect(dt2.month).toBe(4);
|
|
263
|
-
expect(dt2.day).toBe(4);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it("addHours", () => {
|
|
267
|
-
const dt1 = new DateTime(2024, 3, 15, 10);
|
|
268
|
-
const dt2 = dt1.addHours(5);
|
|
269
|
-
|
|
270
|
-
expect(dt2.hour).toBe(15);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it("addMinutes", () => {
|
|
274
|
-
const dt1 = new DateTime(2024, 3, 15, 10, 30);
|
|
275
|
-
const dt2 = dt1.addMinutes(45);
|
|
276
|
-
|
|
277
|
-
expect(dt2.hour).toBe(11);
|
|
278
|
-
expect(dt2.minute).toBe(15);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("addSeconds", () => {
|
|
282
|
-
const dt1 = new DateTime(2024, 3, 15, 10, 30, 45);
|
|
283
|
-
const dt2 = dt1.addSeconds(30);
|
|
284
|
-
|
|
285
|
-
expect(dt2.minute).toBe(31);
|
|
286
|
-
expect(dt2.second).toBe(15);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it("addMilliseconds", () => {
|
|
290
|
-
const dt1 = new DateTime(2024, 3, 15, 10, 30, 45, 500);
|
|
291
|
-
const dt2 = dt1.addMilliseconds(600);
|
|
292
|
-
|
|
293
|
-
expect(dt2.second).toBe(46);
|
|
294
|
-
expect(dt2.millisecond).toBe(100);
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
//#region tick 비교
|
|
299
|
-
|
|
300
|
-
describe("tick 비교", () => {
|
|
301
|
-
it("같은 날짜시간은 같은 tick을 가진다", () => {
|
|
302
|
-
const dt1 = new DateTime(2025, 3, 15, 10, 30, 45, 123);
|
|
303
|
-
const dt2 = new DateTime(2025, 3, 15, 10, 30, 45, 123);
|
|
304
|
-
|
|
305
|
-
expect(dt1.tick).toBe(dt2.tick);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("다른 날짜시간은 다른 tick을 가진다", () => {
|
|
309
|
-
const dt1 = new DateTime(2025, 3, 15, 10, 30, 45, 123);
|
|
310
|
-
const dt2 = new DateTime(2025, 3, 15, 10, 30, 45, 124);
|
|
311
|
-
|
|
312
|
-
expect(dt1.tick).not.toBe(dt2.tick);
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("tick으로 날짜시간 순서를 비교할 수 있다", () => {
|
|
316
|
-
const dt1 = new DateTime(2025, 1, 1, 0, 0, 0);
|
|
317
|
-
const dt2 = new DateTime(2025, 6, 15, 12, 30, 0);
|
|
318
|
-
const dt3 = new DateTime(2025, 12, 31, 23, 59, 59);
|
|
319
|
-
|
|
320
|
-
expect(dt1.tick).toBeLessThan(dt2.tick);
|
|
321
|
-
expect(dt2.tick).toBeLessThan(dt3.tick);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it("밀리초 단위 비교가 가능하다", () => {
|
|
325
|
-
const dt1 = new DateTime(2025, 3, 15, 10, 30, 45, 0);
|
|
326
|
-
const dt2 = new DateTime(2025, 3, 15, 10, 30, 45, 1);
|
|
327
|
-
|
|
328
|
-
expect(dt2.tick - dt1.tick).toBe(1);
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
//#endregion
|
|
333
|
-
|
|
334
|
-
describe("timezoneOffsetMinutes", () => {
|
|
335
|
-
it("현재 타임존 오프셋을 반환한다", () => {
|
|
336
|
-
const dt = new DateTime(2024, 3, 15, 10, 30, 45);
|
|
337
|
-
const expected = new Date().getTimezoneOffset() * -1;
|
|
338
|
-
|
|
339
|
-
expect(dt.timezoneOffsetMinutes).toBe(expected);
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
describe("dayOfWeek", () => {
|
|
344
|
-
it("요일을 반환한다 (일~토: 0~6)", () => {
|
|
345
|
-
// 2024-03-15는 금요일 (5)
|
|
346
|
-
const dt = new DateTime(2024, 3, 15);
|
|
347
|
-
|
|
348
|
-
expect(dt.dayOfWeek).toBe(5);
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
describe("isValid", () => {
|
|
353
|
-
it("유효한 날짜시간은 true를 반환한다", () => {
|
|
354
|
-
const dt = new DateTime(2024, 3, 15, 10, 30, 45);
|
|
355
|
-
expect(dt.isValid).toBe(true);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
it("유효하지 않은 날짜시간은 false를 반환한다", () => {
|
|
359
|
-
const dt = new DateTime(NaN);
|
|
360
|
-
expect(dt.isValid).toBe(false);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it("기본 생성자는 유효한 날짜시간이다", () => {
|
|
364
|
-
const dt = new DateTime();
|
|
365
|
-
expect(dt.isValid).toBe(true);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
describe("toFormatString()", () => {
|
|
370
|
-
it("yyyy-MM-dd 형식", () => {
|
|
371
|
-
const dt = new DateTime(2024, 3, 5);
|
|
372
|
-
|
|
373
|
-
expect(dt.toFormatString("yyyy-MM-dd")).toBe("2024-03-05");
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it("HH:mm:ss 형식", () => {
|
|
377
|
-
const dt = new DateTime(2024, 3, 5, 9, 5, 3);
|
|
378
|
-
|
|
379
|
-
expect(dt.toFormatString("HH:mm:ss")).toBe("09:05:03");
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
describe("toString()", () => {
|
|
384
|
-
it("ISO 8601 형식으로 반환한다", () => {
|
|
385
|
-
const dt = new DateTime(2024, 3, 15, 10, 30, 45, 123);
|
|
386
|
-
const str = dt.toString();
|
|
387
|
-
|
|
388
|
-
expect(str).toMatch(/^2024-03-15T10:30:45\.123[+-]\d{2}:\d{2}$/);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|