Skip to content

Commit 677d370

Browse files
authored
Merge pull request #66 from techniq/simple-format-date
Simple date format via PeriodTypeCode strings (ex. 'day')
2 parents 48b0aea + ab0bb08 commit 677d370

10 files changed

Lines changed: 939 additions & 325 deletions

File tree

.changeset/slimy-bags-beg.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 config option to easily set `type` and additional `options` as single object (ex. `format(number, { type: 'currency', options: { notation: 'compact' } })`)

.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)