index.d.ts 2.6 KB

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