Skip to content

Commit

Permalink
fix: fix DateTime interface (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
korvin89 authored Jan 20, 2023
1 parent 7b467f7 commit c2ddeb4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/dateTime/dateTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,18 @@ describe('DateTime', () => {
.format(DEFAULT_SYSTEM_DATE_FORMAT);
expect(date).toEqual('2021-08-01');
});

it('should set/get hours, minutes, seconds, millisecond', () => {
let date = dateTime({input: TESTED_DATE_STRING});
expect(date.millisecond()).toEqual(0);
expect(date.second()).toEqual(0);
expect(date.minute()).toEqual(0);
expect(date.hour()).toEqual(0);
date = date.hour(10).minute(10).second(10).millisecond(999);
expect(date.millisecond()).toEqual(999);
expect(date.second()).toEqual(10);
expect(date.minute()).toEqual(10);
expect(date.hour()).toEqual(10);
});
});
});
23 changes: 16 additions & 7 deletions src/typings/dateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ export interface DateTime extends Object {
utc: () => DateTime;
utcOffset: () => number;
daysInMonth: () => number;
date: () => number;
month: () => number;
year: () => number;
day: () => number;
hour: () => number;
minute: () => number;
second: () => number;
date(): number;
date(value: number): DateTime;
month(): number;
month(value: number): DateTime;
year(): number;
year(value: number): DateTime;
day(): number;
day(value: number): DateTime;
hour(): number;
hour(value: number): DateTime;
minute(): number;
minute(value: number): DateTime;
second(): number;
second(value: number): DateTime;
millisecond(): number;
millisecond(value: number): DateTime;
}

0 comments on commit c2ddeb4

Please sign in to comment.