declare class DateTimeTool { /** * 1微秒的纳秒数 */ private static readonly nanosecondsOfOneMicrosecond; /** * 1毫秒的微秒数 */ private static readonly microsecondsOfOneMillisecond; /** * 一秒钟的毫秒数 * 1s = 1000ms */ private static readonly millisecondsOfOneSecond; /** * 一分钟的秒数 */ private static readonly secondsOfOneMinute; /** * 一小时的分钟数 */ private static readonly minutesOfOneHour; /** * 一天的小时数 */ private static readonly hoursOfOneDay; /** * 一毫秒的纳秒数 */ private static readonly nanosecondsOfOneMilliseocnd; /** * 一分钟的毫秒数 * 1m = 60s */ private static readonly millisecondsOfOneMinute; /** * 一小时的毫秒数 * 1h = 60m */ private static readonly millisecondsOfOneHour; /** * 一天的毫秒数 * 1d = 24h */ private static readonly millisecondsOfOneDay; /** * 解析日期时间 * @todo 遇到没有碰到过的格式时,更新parse * @returns 时间戳 */ static parse(date: string): number; /** * 格式化时间,默认当前时间 */ static timeFormat(date?: Date, delimiter?: string): string; /** * 格式化日期,默认今天 */ static dateFormat(date?: Date, delimiter?: string): string; /** * 格式化日期时间,默认今天 */ static dateTimeFormat(date?: Date, dateDelimiter?: string, timeDelimiter?: string): string; /** * 时间戳转时间字符串 */ static timestampToTime(timestamp: number, delimiter?: string): string; /** * 时间戳转日期字符串 */ static timestampToDate(timestamp: number, delimiter?: string): string; /** * 时间戳转日期时间字符串 */ static timestampToDateTime(timestamp: number, dateDelimiter?: string, timeDelimiter?: string): string; /** * 获取n天以前时间和当前日期时间 */ static getNthDayBefore(n: number, end?: Date): Date[]; /** * 获取n天以后时间 */ static getNthDayAfter(n: number, before?: Date): Date[]; /** * 获取n小时之前到当前时间 */ static getNthHourBefore(n: number, end?: Date): Date[]; /** * 获取n月以前时间到当前月时间 */ static getNthMonthBefore(n?: number, end?: Date): Date[]; /** * 是否是闰年 * * 能被4整除且不能被100整除 * 或者能被400整除 */ static isLeapYear(date?: Date): boolean; /** * 两个日期相差的时间戳 */ static diffTimestamp(start: Date | number, end: Date | number): number; /** * 两个日期相差的秒数 */ static diffSeconds(start: Date | number, end: Date | number): number; /** * 两个日期相差的分钟数 */ static diffMinutes(start: Date | number, end: Date | number): number; /** * 两个日期相差的小时数 */ static diffHours(start: Date | number, end: Date | number): number; /** * 两个日期之间相差多少天 */ static diffDays(start: Date | number, end: Date | number): number; /** * 设置到当前天的开始 */ static toDayBegin(date: Date): Date; /** * 设置到当前的结束 */ static toDayEnd(date: Date): Date; /** * 往后加几天 * @param date 需要修改的 Date 或者 milliseconds * @param days 改变的天数 */ static addDays(date: Date | number, days: number): Date; /** * 获取当周的日期范围 */ static getCurrentWeek(date: Date | number, changeTime?: boolean): Date[]; /** * 毫秒数转秒数 * 不足1秒直接舍弃 * @param milliseconds 毫秒数 */ static getSecondsFromMilliseconds(milliseconds: number): number; /** * 毫秒数转分钟数 * 不足1分钟直接舍弃 * @param milliseconds 毫秒数 */ static getMinutesFromMilliseconds(milliseconds: number): number; /** * 毫秒数转小时数 * 不足1小时直接舍弃 * @param milliseconds 毫秒数 */ static getHoursFromMilliseconds(milliseconds: number): number; /** * 毫秒数转天数 * 不足一天直接舍弃 * @param milliseconds 毫秒数 */ static getDayCountFromMilliseconds(milliseconds: number): number; /** * 毫秒数格式化 * @param milliseconds 毫秒数 * @returns hh:mm:ss */ static millisecondsFormat(milliseconds: number): string; /** * 秒数格式化 * * @param seconds 秒数 seconds >= 0 * @returns hh:mm:ss */ static secondsFormat(seconds: number): string; } export default DateTimeTool;