|
8 | 8 | utcToLocalTimeZone, |
9 | 9 | addSecondsToLocalTimestamp, |
10 | 10 | reformatInIsoLocal, |
| 11 | + reformatUtcTimestamp, |
11 | 12 | } from '../src'; |
12 | 13 |
|
13 | 14 | describe('timeSeries', () => { |
@@ -529,3 +530,35 @@ describe('reformatInIsoLocal', () => { |
529 | 530 | expect(reformatInIsoLocal(timestamp)).toBe(expected); |
530 | 531 | }); |
531 | 532 | }); |
| 533 | + |
| 534 | +describe('reformatUtcTimestamp', () => { |
| 535 | + it('should format timestamp to YYYY-MM-DDTHH:mm:ss.SSS', () => { |
| 536 | + expect(reformatUtcTimestamp('YYYY-MM-DDTHH:mm:ss.SSS', '2025-02-28T12:34:56Z')) |
| 537 | + .toBe('2025-02-28T12:34:56.000'); |
| 538 | + }); |
| 539 | + |
| 540 | + it('should format timestamp to YYYY-MM-DDTHH:mm:ss', () => { |
| 541 | + expect(reformatUtcTimestamp('YYYY-MM-DDTHH:mm:ss', '2025-02-28T12:34:56Z')) |
| 542 | + .toBe('2025-02-28T12:34:56'); |
| 543 | + }); |
| 544 | + |
| 545 | + it('should format timestamp to YYYY-MM-DD HH:mm:ss.SSS', () => { |
| 546 | + expect(reformatUtcTimestamp('YYYY-MM-DD HH:mm:ss.SSS', '2025-02-28T12:34:56Z')) |
| 547 | + .toBe('2025-02-28 12:34:56.000'); |
| 548 | + }); |
| 549 | + |
| 550 | + it('should format timestamp to YYYY-MM-DD HH:mm:ss', () => { |
| 551 | + expect(reformatUtcTimestamp('YYYY-MM-DD HH:mm:ss', '2025-02-28T12:34:56Z')) |
| 552 | + .toBe('2025-02-28 12:34:56'); |
| 553 | + }); |
| 554 | + |
| 555 | + it('should handle timestamps with milliseconds', () => { |
| 556 | + expect(reformatUtcTimestamp('YYYY-MM-DDTHH:mm:ss.SSS', '2025-02-28T12:34:56.789Z')) |
| 557 | + .toBe('2025-02-28T12:34:56.789'); |
| 558 | + }); |
| 559 | + |
| 560 | + it('should handle timestamps without timezone info', () => { |
| 561 | + expect(reformatUtcTimestamp('YYYY-MM-DDTHH:mm:ss.SSS', '2025-02-28 12:34:56')) |
| 562 | + .toBe('2025-02-28T12:34:56.000'); |
| 563 | + }); |
| 564 | +}); |
0 commit comments