Skip to content

Commit

Permalink
fix: work with years from 0 to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Nov 22, 2023
1 parent f6d2904 commit 2702aa9
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 142 deletions.
15 changes: 15 additions & 0 deletions src/dateTime/dateTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,20 @@ describe('DateTime', () => {

expect(dateTime({input: '20130531', format: 'YYYYMMDD'}).month(3).month()).toBe(3);
});

it('should work with years >= 0 and < 100 ', () => {
const date = dateTime({input: '0001-01-12T00:00:00Z', timeZone: 'Europe/Amsterdam'});
expect(date.toISOString()).toBe('0001-01-12T00:00:00.000Z');
expect(date.startOf('s').toISOString()).toBe('0001-01-12T00:00:00.000Z');
expect(date.startOf('s').valueOf()).toBe(date.valueOf());
expect(date.set({year: 2, month: 1, date: 20}).toISOString()).toBe(
'0002-02-20T00:00:00.000Z',
);
expect(date.add(1, 'year').toISOString()).toBe('0002-01-12T00:00:00.000Z');
expect(date.subtract(1, 'year').toISOString()).toBe('0000-01-12T00:00:00.000Z');

expect(date.isSame(date)).toBe(true);
expect(date.valueOf()).toBe(date.startOf('ms').valueOf());
});
});
});
Loading

0 comments on commit 2702aa9

Please sign in to comment.