UNPKG

@cainiaofe/cn-utils

Version:

菜鸟前端基础工具库

71 lines (70 loc) 1.87 kB
import { TLanguage } from '@cainiaofe/cn-i18n'; import { ThisContext } from '../common/type'; import { AvailableDate, FormatOpts, Timestamp, Timezone } from './type'; /** * 根据语种信息获取日期格式化配置 * @param lang 语种 * @returns */ export declare const getDateFormatConf: (lang: TLanguage) => { s: string; m: string; H: string; D: string; M: string; W: string; Q: string; Y: string; HH: string; Hm: string; Hms: string; }; /** * 获取系统时区信息 * @returns */ export declare const getTimezone: (this: ThisContext) => string; /** * 根据当前语种&时区格式化时间戳 * @param this * @param num * @param opts * @returns */ export declare const dateFormat: (this: ThisContext, num: Timestamp, opts: FormatOpts) => string; /** * 根据当前语种&时区获取时间戳 * @param this * @param dateStr string * @param opts FormatOpts * @returns */ export declare const dateTimestamp: (this: ThisContext, dateStr?: string, opts?: FormatOpts) => number; /** * 根据时间戳获取当前日期偏移量 * @param this * @param num * @param timezone */ export declare const getTimezoneOffset: (this: ThisContext, num: Timestamp, timezone: Timezone) => { offset: number; offsetText: string; }; /** * 根据时间戳获取当前日期偏移量 * @param this * @param num * @param timezone * @param lang * @returns */ export declare const getTimezoneName: (this: ThisContext, num?: Timestamp, timezone?: Timezone, lang?: TLanguage) => string | null; /** * 设置 dayjs 对象时区 * @param this * @param day * @param timezone * @param keepLocalTime 是否保持本地时间 * @returns 新的 dayjs 对象 */ export declare const dayjsTz: (this: ThisContext, day: AvailableDate, timezone?: Timezone, keepLocalTime?: boolean) => import("dayjs").Dayjs;