UNPKG

@cainiaofe/cn-utils

Version:

菜鸟前端基础工具库

66 lines (65 loc) 1.89 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) => any; /** * 将国际标准格式兑换成本地格式 * @param stdFormat * @param lang 语种 * @returns */ export declare function getDateFormatByStd(stdFormat: string, lang: TLanguage): string; /** * 获取系统时区信息 * @returns */ export declare const getTimezone: (this: ThisContext) => string; /** * 根据时间戳获取当前日期偏移量 * @param this * @param num * @param timezone * @param lang * @returns */ export declare const getTimezoneName: (this: ThisContext, num?: Timestamp, timezone?: Timezone, lang?: TLanguage) => string | null; /** * 根据当前语种&时区格式化时间戳 * @param this * @param num * @param opts * @returns */ export declare const dateFormat: (this: ThisContext, num: Timestamp, opts: any) => 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; }; /** * 设置 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;