Skip to content

Commit eaca635

Browse files
committed
feat(format): Support passing PeriodTypeCode strings to easily format dates (ex. format(date, 'day'))
1 parent 48b0aea commit eaca635

File tree

8 files changed

+749
-286
lines changed

8 files changed

+749
-286
lines changed

.changeset/two-doodles-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@layerstack/utils': patch
3+
---
4+
5+
feat(format): Support passing PeriodTypeCode strings to easily format dates (ex. `format(date, 'day')`)

packages/utils/src/lib/array.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect } from 'vitest';
22

33
import { greatestAbs, sumObjects } from './array.js';
4-
import { testDate } from './date.test.js';
4+
import { testDateStr } from './date.test.js';
55

66
describe('sumObjects', () => {
77
it('Sum array of objects ', () => {
@@ -11,7 +11,7 @@ describe('sumObjects', () => {
1111
{ one: null, two: null, three: null, four: null },
1212
{ one: NaN, two: NaN, three: NaN, four: NaN },
1313
{ one: 'NaN', two: 'NaN', three: 'NaN', four: 'NaN' },
14-
{ one: '3', two: 6, four: '4', startDate: new Date(testDate) },
14+
{ one: '3', two: 6, four: '4', startDate: new Date(testDateStr) },
1515
];
1616

1717
const actual = sumObjects(values);
@@ -21,7 +21,7 @@ describe('sumObjects', () => {
2121
three: 9,
2222
four: 4,
2323
extra: 0,
24-
startDate: +new Date(testDate),
24+
startDate: +new Date(testDateStr),
2525
};
2626

2727
expect(actual).toEqual(expected);

0 commit comments

Comments
 (0)