File tree Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ Examples:
60
60
61
61
| | day.js (via time-lib) | LocalTime | LocalDate |
62
62
| ----------------------------------- | ------------------------------------ | ------------------------------ | ------------------------------ |
63
- | now | dayjs() | localTimeNow() | |
64
- | today | dayjs().startOf('day') | | localDateToday() |
63
+ | now | dayjs() | localTime.now() | |
64
+ | today | dayjs().startOf('day') | | localDate.today() |
65
65
| create from unixtimestamp | dayjs.unix(ts) | localTime(ts) | |
66
66
| parse from ISO8601 date string | dayjs(str) | | localDate(str) |
67
67
| parse from ISO8601 date+time string | dayjs(str) | localTime(str) | |
Original file line number Diff line number Diff line change @@ -42,13 +42,13 @@ test('basic', () => {
42
42
expect ( ld . month ( 7 ) . daysInMonth ( ) ) . toBe ( 31 )
43
43
expect ( ld . month ( 2 ) . daysInMonth ( ) ) . toBe ( 29 )
44
44
45
- expect ( localDate . orUndefined ( ) ) . toBeUndefined ( )
45
+ expect ( localDate . orUndefined ( undefined ) ) . toBeUndefined ( )
46
46
expect ( localDate . orUndefined ( null ) ) . toBeUndefined ( )
47
47
expect ( localDate . orUndefined ( 0 as any ) ) . toBeUndefined ( )
48
48
expect ( localDate . orUndefined ( str ) ?. toString ( ) ) . toBe ( str )
49
49
50
50
expect ( localDate . today ( ) . toISODate ( ) ) . toBeDefined ( )
51
- expect ( localDate . orToday ( ) . toISODate ( ) ) . toBe ( localDate . today ( ) . toISODate ( ) )
51
+ expect ( localDate . orToday ( undefined ) . toISODate ( ) ) . toBe ( localDate . today ( ) . toISODate ( ) )
52
52
expect ( localDate . orToday ( ld ) . toISODate ( ) ) . toBe ( ld . toISODate ( ) )
53
53
54
54
expect ( ( ) => localDate ( undefined as any ) ) . toThrowErrorMatchingInlineSnapshot (
Original file line number Diff line number Diff line change @@ -665,14 +665,14 @@ class LocalDateFactory {
665
665
*
666
666
* Similar to `localDate.orToday`, but that will instead return Today on falsy input.
667
667
*/
668
- orUndefined ( d ? : LocalDateInput | null ) : LocalDate | undefined {
668
+ orUndefined ( d : LocalDateInput | null | undefined ) : LocalDate | undefined {
669
669
return d ? this . of ( d ) : undefined
670
670
}
671
671
672
672
/**
673
673
* Creates a LocalDate from the input, unless it's falsy - then returns localDate.today.
674
674
*/
675
- orToday ( d ? : LocalDateInput | null ) : LocalDate {
675
+ orToday ( d : LocalDateInput | null | undefined ) : LocalDate {
676
676
return d ? this . of ( d ) : this . today ( )
677
677
}
678
678
}
Original file line number Diff line number Diff line change @@ -117,13 +117,13 @@ test('basic', () => {
117
117
expect ( lt . month ( 2 ) . daysInMonth ( ) ) . toBe ( 28 )
118
118
expect ( lt . month ( 4 ) . daysInMonth ( ) ) . toBe ( 30 )
119
119
120
- expect ( localTime . orUndefined ( ) ) . toBeUndefined ( )
120
+ expect ( localTime . orUndefined ( undefined ) ) . toBeUndefined ( )
121
121
expect ( localTime . orUndefined ( null ) ) . toBeUndefined ( )
122
122
expect ( localTime . orUndefined ( 0 as any ) ) . toBeUndefined ( )
123
123
expect ( localTime . orUndefined ( start ) ?. toISODate ( ) ) . toBe ( '2022-01-01' )
124
124
125
125
expect ( localTime . now ( ) . toString ( ) ) . toBeDefined ( )
126
- expect ( localTime . orNow ( ) . toString ( ) ) . toBeDefined ( )
126
+ expect ( localTime . orNow ( undefined ) . toString ( ) ) . toBeDefined ( )
127
127
expect ( localTime . orNow ( lt ) . toISODate ( ) ) . toBe ( lt . toISODate ( ) )
128
128
129
129
expect ( ( ) => localTime ( undefined as any ) ) . toThrowErrorMatchingInlineSnapshot (
Original file line number Diff line number Diff line change @@ -638,14 +638,14 @@ class LocalTimeFactory {
638
638
*
639
639
* `localTime` function will instead return LocalTime of `now` for falsy input.
640
640
*/
641
- orUndefined ( d ? : LocalTimeInput | null ) : LocalTime | undefined {
641
+ orUndefined ( d : LocalTimeInput | null | undefined ) : LocalTime | undefined {
642
642
return d ? this . of ( d ) : undefined
643
643
}
644
644
645
645
/**
646
646
* Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now
647
647
*/
648
- orNow ( d ? : LocalTimeInput | null ) : LocalTime {
648
+ orNow ( d : LocalTimeInput | null | undefined ) : LocalTime {
649
649
return d ? this . of ( d ) : this . now ( )
650
650
}
651
651
You can’t perform that action at this time.
0 commit comments