index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /// <reference path="./locale/index.d.ts" />
  2. export = dayjs;
  3. declare function dayjs (date?: dayjs.ConfigType, option?: dayjs.OptionType, locale?: string): dayjs.Dayjs
  4. declare namespace dayjs {
  5. export type ConfigType = string | number | Date | Dayjs
  6. export type OptionType = { locale?: string, format?: string, utc?: boolean } | string
  7. type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
  8. export type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | UnitTypeShort;
  9. export type OpUnitType = UnitType | "week" | 'w';
  10. export type QUnitType = UnitType | "quarter" | 'Q';
  11. class Dayjs {
  12. constructor (config?: ConfigType)
  13. clone(): Dayjs
  14. isValid(): boolean
  15. year(): number
  16. year(value: number): Dayjs
  17. month(): number
  18. month(value: number): Dayjs
  19. date(): number
  20. date(value: number): Dayjs
  21. day(): number
  22. day(value: number): Dayjs
  23. hour(): number
  24. hour(value: number): Dayjs
  25. minute(): number
  26. minute(value: number): Dayjs
  27. second(): number
  28. second(value: number): Dayjs
  29. millisecond(): number
  30. millisecond(value: number): Dayjs
  31. set(unit: UnitType, value: number): Dayjs
  32. get(unit: UnitType): number
  33. add(value: number, unit: OpUnitType): Dayjs
  34. subtract(value: number, unit: OpUnitType): Dayjs
  35. startOf(unit: OpUnitType): Dayjs
  36. endOf(unit: OpUnitType): Dayjs
  37. format(template?: string): string
  38. diff(date: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number
  39. valueOf(): number
  40. unix(): number
  41. daysInMonth(): number
  42. toDate(): Date
  43. toJSON(): string
  44. toISOString(): string
  45. toString(): string
  46. utcOffset(): number
  47. isBefore(date: ConfigType, unit?: OpUnitType): boolean
  48. isSame(date: ConfigType, unit?: OpUnitType): boolean
  49. isAfter(date: ConfigType, unit?: OpUnitType): boolean
  50. locale(): string
  51. locale(preset: string | ILocale, object?: Partial<ILocale>): Dayjs
  52. }
  53. export type PluginFunc<T = unknown> = (option: T, c: typeof Dayjs, d: typeof dayjs) => void
  54. export function extend<T = unknown>(plugin: PluginFunc<T>, option?: T): Dayjs
  55. export function locale(preset?: string | ILocale, object?: Partial<ILocale>, isLocal?: boolean): string
  56. export function isDayjs(d: any): d is Dayjs
  57. export function unix(t: number): Dayjs
  58. const Ls : { [key: string] : ILocale }
  59. }