qw-utils-vanguard
Version:
qw Utils package
68 lines (67 loc) • 2.02 kB
TypeScript
import dayjs from 'dayjs';
/**
* 时间工具类
*/
export declare class timeUtils {
constructor();
/**
* 获取当前的时分秒
* @returns
*/
getCurrentTime(): string;
/**
* 获取当前的年月日
* @returns
*/
getDate(): string;
/**
* 获取当前时间
*/
nowDate(): Date;
/**
* 格式化日期
* @param date 日期对象或时间戳
* @param format 格式化字符串,默认为 'YYYY-MM-DD HH:mm:ss'
*/
format(date: dayjs.ConfigType, format?: string): string;
/**
* 判断一个值是否为日期对象
* @param value 待判断的值
*/
isDate(value: any): boolean;
/**
* 获取指定日期所在月份的天数
* @param date 日期对象或时间戳
*/
getDaysInMonth(date: dayjs.ConfigType): number;
/**
* 在指定日期上添加指定的时间量
* @param date 日期对象或时间戳
* @param amount 时间量(正数为加,负数为减)
* @param unit 时间单位,默认为 'day'
*/
addDate(date: dayjs.ConfigType, amount: number, unit?: dayjs.ManipulateType): Date;
/**
* 计算两个日期之间相差的时间量
* @param start 起始日期对象或时间戳
* @param end 结束日期对象或时间戳
* @param unit 时间单位,默认为 'day'
*/
diffDate(start: dayjs.ConfigType, end: dayjs.ConfigType, unit?: dayjs.UnitType): number;
/**
* 判断一个日期是否在指定的时间范围内
* @param date 待判断的日期对象或时间戳
* @param start 起始日期对象或时间戳
* @param end 结束日期对象或时间戳
*/
isBetween(date: dayjs.ConfigType, start: dayjs.ConfigType, end: dayjs.ConfigType): boolean;
/**
* 获取当前时间戳(毫秒)
*/
unix(): number;
/**
* 将时间戳转换为日期对象
* @param timestamp 时间戳(毫秒)
*/
toDate(timestamp: number): Date;
}