@opensig/opendesign
Version:
29 lines (28 loc) • 1.15 kB
TypeScript
/**
* 时间前补零
*/
export declare const pad: (n: number, maxLength?: number) => string;
/**
* 格式化时间为字符串,入参month为自然语义月,从1开始
* 如果不需要年月日时,自动补全年月日到1970-1-1
*/
export declare const dateTimeNumberToString: ({ year, month, date, hour, minute, second }: Partial<Record<"year" | "month" | "date" | "hour" | "minute" | "second", number | null>>, { format, timeOnly, }: {
/**
* dayjs支持的format
* @example YYYY-MM-DD HH:mm:ss
*/
format: string;
/**
* 是否需要年月日信息
*/
timeOnly?: boolean;
}) => string | undefined;
/**
* 解析时间字符串为自然语义数字,month从1开始,自动处理超边界
*/
export declare function stringToDateTimeNumber(str: string | null | undefined, options?: {
timeOnly: true;
}): Record<'hour' | 'minute' | 'second', number | null> | undefined;
export declare function stringToDateTimeNumber(str: string | null | undefined, options?: {
timeOnly?: false | undefined;
}): Record<'year' | 'month' | 'date' | 'hour' | 'minute' | 'second', number | null> | undefined;