Skip to content

Commit

Permalink
chore: Added shorthand units to UnitType (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
dotlouis authored and iamkun committed Feb 2, 2019
1 parent 689e167 commit abab171
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ declare namespace dayjs {

export type OptionType = { locale: string }

export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date'
type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'quarter' | 'year' | 'date' | UnitTypeShort;

type OpUnitTypeShort = 'w'
export type OpUnitType = UnitType | "week" | OpUnitTypeShort;

interface DayjsObject {
years: number
Expand Down Expand Up @@ -44,17 +48,17 @@ declare namespace dayjs {

set(unit: UnitType, value: number): Dayjs

add(value: number, unit: UnitType): Dayjs
add(value: number, unit: OpUnitType): Dayjs

subtract(value: number, unit: UnitType): Dayjs
subtract(value: number, unit: OpUnitType): Dayjs

startOf(unit: UnitType): Dayjs
startOf(unit: OpUnitType): Dayjs

endOf(unit: UnitType): Dayjs
endOf(unit: OpUnitType): Dayjs

format(template?: string): string

diff(dayjs: Dayjs, unit: UnitType, float?: boolean): number
diff(dayjs: Dayjs, unit: OpUnitType, float?: boolean): number

valueOf(): number

Expand All @@ -74,11 +78,11 @@ declare namespace dayjs {

toString(): string

isBefore(dayjs: Dayjs, unit?: UnitType): boolean
isBefore(dayjs: Dayjs, unit?: OpUnitType): boolean

isSame(dayjs: Dayjs, unit?: UnitType): boolean
isSame(dayjs: Dayjs, unit?: OpUnitType): boolean

isAfter(dayjs: Dayjs, unit?: UnitType): boolean
isAfter(dayjs: Dayjs, unit?: OpUnitType): boolean

isLeapYear(): boolean

Expand Down

0 comments on commit abab171

Please sign in to comment.