diff --git a/docs/date.md b/docs/date.md index 24f1d653..d1d818ef 100644 --- a/docs/date.md +++ b/docs/date.md @@ -60,8 +60,8 @@ Examples: | | day.js (via time-lib) | LocalTime | LocalDate | | ----------------------------------- | ------------------------------------ | ------------------------------ | ------------------------------ | -| now | dayjs() | localTimeNow() | | -| today | dayjs().startOf('day') | | localDateToday() | +| now | dayjs() | localTime.now() | | +| today | dayjs().startOf('day') | | localDate.today() | | create from unixtimestamp | dayjs.unix(ts) | localTime(ts) | | | parse from ISO8601 date string | dayjs(str) | | localDate(str) | | parse from ISO8601 date+time string | dayjs(str) | localTime(str) | | diff --git a/src/datetime/localDate.test.ts b/src/datetime/localDate.test.ts index 09ef9ed0..a21a494e 100644 --- a/src/datetime/localDate.test.ts +++ b/src/datetime/localDate.test.ts @@ -42,13 +42,13 @@ test('basic', () => { expect(ld.month(7).daysInMonth()).toBe(31) expect(ld.month(2).daysInMonth()).toBe(29) - expect(localDate.orUndefined()).toBeUndefined() + expect(localDate.orUndefined(undefined)).toBeUndefined() expect(localDate.orUndefined(null)).toBeUndefined() expect(localDate.orUndefined(0 as any)).toBeUndefined() expect(localDate.orUndefined(str)?.toString()).toBe(str) expect(localDate.today().toISODate()).toBeDefined() - expect(localDate.orToday().toISODate()).toBe(localDate.today().toISODate()) + expect(localDate.orToday(undefined).toISODate()).toBe(localDate.today().toISODate()) expect(localDate.orToday(ld).toISODate()).toBe(ld.toISODate()) expect(() => localDate(undefined as any)).toThrowErrorMatchingInlineSnapshot( diff --git a/src/datetime/localDate.ts b/src/datetime/localDate.ts index 53a0d292..40e375f1 100644 --- a/src/datetime/localDate.ts +++ b/src/datetime/localDate.ts @@ -665,14 +665,14 @@ class LocalDateFactory { * * Similar to `localDate.orToday`, but that will instead return Today on falsy input. */ - orUndefined(d?: LocalDateInput | null): LocalDate | undefined { + orUndefined(d: LocalDateInput | null | undefined): LocalDate | undefined { return d ? this.of(d) : undefined } /** * Creates a LocalDate from the input, unless it's falsy - then returns localDate.today. */ - orToday(d?: LocalDateInput | null): LocalDate { + orToday(d: LocalDateInput | null | undefined): LocalDate { return d ? this.of(d) : this.today() } } diff --git a/src/datetime/localTime.test.ts b/src/datetime/localTime.test.ts index af0c279e..c031a2b7 100644 --- a/src/datetime/localTime.test.ts +++ b/src/datetime/localTime.test.ts @@ -117,13 +117,13 @@ test('basic', () => { expect(lt.month(2).daysInMonth()).toBe(28) expect(lt.month(4).daysInMonth()).toBe(30) - expect(localTime.orUndefined()).toBeUndefined() + expect(localTime.orUndefined(undefined)).toBeUndefined() expect(localTime.orUndefined(null)).toBeUndefined() expect(localTime.orUndefined(0 as any)).toBeUndefined() expect(localTime.orUndefined(start)?.toISODate()).toBe('2022-01-01') expect(localTime.now().toString()).toBeDefined() - expect(localTime.orNow().toString()).toBeDefined() + expect(localTime.orNow(undefined).toString()).toBeDefined() expect(localTime.orNow(lt).toISODate()).toBe(lt.toISODate()) expect(() => localTime(undefined as any)).toThrowErrorMatchingInlineSnapshot( diff --git a/src/datetime/localTime.ts b/src/datetime/localTime.ts index 7e8cc6a0..e60055a2 100644 --- a/src/datetime/localTime.ts +++ b/src/datetime/localTime.ts @@ -638,14 +638,14 @@ class LocalTimeFactory { * * `localTime` function will instead return LocalTime of `now` for falsy input. */ - orUndefined(d?: LocalTimeInput | null): LocalTime | undefined { + orUndefined(d: LocalTimeInput | null | undefined): LocalTime | undefined { return d ? this.of(d) : undefined } /** * Creates a LocalTime from the input, unless it's falsy - then returns LocalTime.now */ - orNow(d?: LocalTimeInput | null): LocalTime { + orNow(d: LocalTimeInput | null | undefined): LocalTime { return d ? this.of(d) : this.now() }