time.d.ts 858 B

1234567891011121314151617181920212223242526
  1. declare const scale: readonly ["year", "month", "day", "hour", "minute", "second"];
  2. type TimeScale = (typeof scale)[number];
  3. export declare function parseDate(date: Date | string): Date;
  4. /**
  5. * 生成时间格式化
  6. * @param maxUnit 最大时间单位
  7. * @param minUnit 最小时间单位
  8. */
  9. export declare function getMask([maxUnit, minUnit]: [TimeScale, TimeScale]): string;
  10. /**
  11. * 格式化时间
  12. */
  13. export declare function formatTime(date: Date, mask: string): string;
  14. /**
  15. * 获取两个时间的差值,单位毫秒
  16. */
  17. export declare function getTimeDiff(a: Date | string, b: Date | string): number;
  18. /**
  19. * 获取时间跨度
  20. */
  21. export declare function getTimeScale(a: Date | string, b: Date | string): TimeScale;
  22. /**
  23. * 获取给定时间的开始时间
  24. */
  25. export declare function getTimeStart(date: Date, scale: TimeScale): string;
  26. export {};