Skip to content

Commit

Permalink
Merge e69bd82 into 00c223b
Browse files Browse the repository at this point in the history
  • Loading branch information
FourwingsY authored Mar 31, 2023
2 parents 00c223b + e69bd82 commit ea4c9f6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
7 changes: 7 additions & 0 deletions test/plugin/isSameOrAfter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ test('is same or after without units', () => {
expect(+m).toEqual(+mCopy, 'isSameOrAfter second should not change moment')
})

test('is same or after without date', () => {
const past = dayjs().subtract(1, 'day')
const future = dayjs().add(1, 'day')
expect(past.isSameOrAfter()).toBe(false, 'past is before now')
expect(future.isSameOrAfter()).toBe(true, 'future is not before now')
})

test('is same or after month', () => {
const m = dayjs(new Date(2011, 2, 3, 4, 5, 6, 7))
const mCopy = dayjs(m)
Expand Down
7 changes: 7 additions & 0 deletions test/plugin/isSameOrBefore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ test('is same or before without units', () => {
expect(+m).toEqual(+mCopy, 'isSameOrBefore second should not change moment')
})

test('is same or before without date', () => {
const past = dayjs().subtract(1, 'day')
const future = dayjs().add(1, 'day')
expect(past.isSameOrBefore()).toBe(true, 'past is before now')
expect(future.isSameOrBefore()).toBe(false, 'future is not before now')
})

test('is same or before year', () => {
const m = dayjs(new Date(2011, 1, 2, 3, 4, 5, 6))
const mCopy = dayjs(m)
Expand Down
6 changes: 3 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ declare namespace dayjs {
*
* Docs: https://day.js.org/docs/en/query/is-before
*/
isBefore(date: ConfigType, unit?: OpUnitType): boolean
isBefore(date?: ConfigType, unit?: OpUnitType): boolean
/**
* This indicates whether the Day.js object is the same as the other supplied date-time.
* ```
Expand All @@ -394,7 +394,7 @@ declare namespace dayjs {
* ```
* Docs: https://day.js.org/docs/en/query/is-same
*/
isSame(date: ConfigType, unit?: OpUnitType): boolean
isSame(date?: ConfigType, unit?: OpUnitType): boolean
/**
* This indicates whether the Day.js object is after the other supplied date-time.
* ```
Expand All @@ -408,7 +408,7 @@ declare namespace dayjs {
*
* Docs: https://day.js.org/docs/en/query/is-after
*/
isAfter(date: ConfigType, unit?: OpUnitType): boolean
isAfter(date?: ConfigType, unit?: OpUnitType): boolean

locale(): string

Expand Down
2 changes: 1 addition & 1 deletion types/plugin/isSameOrAfter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export = plugin

declare module 'dayjs' {
interface Dayjs {
isSameOrAfter(date: ConfigType, unit?: OpUnitType): boolean
isSameOrAfter(date?: ConfigType, unit?: OpUnitType): boolean
}
}
2 changes: 1 addition & 1 deletion types/plugin/isSameOrBefore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export = plugin

declare module 'dayjs' {
interface Dayjs {
isSameOrBefore(date: ConfigType, unit?: OpUnitType): boolean
isSameOrBefore(date?: ConfigType, unit?: OpUnitType): boolean
}
}
6 changes: 3 additions & 3 deletions types/plugin/isoWeek.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ declare module 'dayjs' {

endOf(unit: ISOUnitType): Dayjs

isSame(date: ConfigType, unit?: ISOUnitType): boolean
isSame(date?: ConfigType, unit?: ISOUnitType): boolean

isBefore(date: ConfigType, unit?: ISOUnitType): boolean
isBefore(date?: ConfigType, unit?: ISOUnitType): boolean

isAfter(date: ConfigType, unit?: ISOUnitType): boolean
isAfter(date?: ConfigType, unit?: ISOUnitType): boolean
}
}
6 changes: 3 additions & 3 deletions types/plugin/quarterOfYear.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ declare module 'dayjs' {

endOf(unit: QUnitType | OpUnitType): Dayjs

isSame(date: ConfigType, unit?: QUnitType): boolean
isSame(date?: ConfigType, unit?: QUnitType): boolean

isBefore(date: ConfigType, unit?: QUnitType): boolean
isBefore(date?: ConfigType, unit?: QUnitType): boolean

isAfter(date: ConfigType, unit?: QUnitType): boolean
isAfter(date?: ConfigType, unit?: QUnitType): boolean
}
}

0 comments on commit ea4c9f6

Please sign in to comment.