study-kgxx-test3
Version:
ts工具函数
21 lines (20 loc) • 1.15 kB
TypeScript
/**
* @name simpleFormatTimestamp
* @author 李嘉豪
* @description 将传入的时间戳格式化为指定格式
* @param { number | string | undefined | null } timestamp 时间戳
* @param { FormatType } format 格式化方式
* @returns { string } 格式化后的时间
*/
export declare function simpleFormatTimestamp(timestamp: number | string | undefined | null, format?: FormatType): string;
/**
* @name simpleGetDate
* @author 李嘉豪
* @description 根据时间戳获取所需要的年月日时分秒
* @param { number | string | undefined | null } timestamp 时间戳
* @param { GetDateType } date 获取年月日时分秒哪个值
* @returns { number } 返回的值
*/
export declare function simpleGetDate(timestamp: number | string | undefined | null, date?: GetDateType): number;
export type FormatType = 'yyyy-MM-dd HH:mm:ss' | 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH' | 'yyyy-MM-dd' | 'yyyy-MM' | 'yyyy' | 'yyyy年MM月dd日 HH时mm分ss秒' | 'yyyy年MM月dd日 HH时mm分' | 'yyyy年MM月dd日 HH时' | 'yyyy年MM月dd日' | 'yyyy年MM月' | 'yyyy年';
export type GetDateType = 'Y' | 'M' | 'D' | 'H' | 'm' | 's';