/** * Copyright (c) 2022 - present TinyVue Authors. * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. * * Use of this source code is governed by an MIT-style license. * * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. * */ /** * 判断年份是否为闰年。 * * isLeapYear(2017) // false * isLeapYear(2000) // true * * @param {Number} year 年份 * @returns {Boolean} */ export declare const isLeapYear: (year: any) => boolean; /** * 将字符串或数字转换成 Date 类型。 * * toDate('2008/02/02') // new Date(2008, 1, 2) * toDate(Date.UTC(2008, 1, 2)) // new Date(Date.UTC(2008, 1, 2)) * toDate('2008/2/2', 'yyyy/M/d') // new Date(2008, 1, 2) * toDate('2008/02') // new Date(2008, 1, 1) * toDate('02/2008') // new Date(2008, 1, 1) * toDate('2008-02-01T20:08+08:00') // new Date(Date.UTC(2008, 0, 31, 16)) * toDate('2008-02-01T04:08-08:00') // new Date(Date.UTC(2008, 1, 1, 8)) * * @param {String|Number} value 日期类型字符串或数字 * @param {String} [dateFormat] 转换格式 * * 当 value 为字符串类型时,如果不提供,则尽可能按常见格式去解析。 * 常见格式为 yyyy[/-]MM[/-]dd hh:mm:ss.SSS, MM[/-]dd [/-]yyyy hh:mm:ss.SSS 及 ISO8601 时间格式。 * * 如果提供,则按具体格式严格匹配解析,并且年份必须为4位。 * - yyyy 代表年份 * - M 或 MM 代表1位或2位的月份 * - d 或 dd 代表1位或2位的天数 * - h 或 hh 代表24小时的1位或2位的小时 * - m 或 mm 代表1位或2位的分钟, * - s 或 ss 代表1位或2位的秒 * - S 或 SS 或 SSS 代表1位或2位或3位的毫秒 * * @param {String} [minDate] 最小时间,默认为 0001-01-01 00:00:00.000 * @returns {Date} */ export declare const toDate: (value: any, dateFormat: any, minDate: any) => any; /** * 将 Date 实例转换成日期字符串。 * 当 date 为日期字符串时,如果只有2个参数,则第2个参数为格式化后的格式化字符串 * 如果有3个参数,则第2个参数为转换的格式化参数,第3个参数为格式化后的格式化参数 * * let date = new Date(2014, 4, 4, 1, 2, 3, 4) * format(date) // "2014/05/04 01:02:03" * format(date, 'yyyy/MM/dd hh:mm:ss.SSS') // "2014/05/04 01:02:03.004" * format(date, 'yyyy/MM/dd hh:mm:ss.SSSZ') // "2014/05/04 01:02:03.004+0800" * format(date, 'yyyy年MM月dd日 hh时mm分ss秒SSS毫秒') // "2014年05月04日 01时02分03秒004毫秒" * format('2008/01/02', 'yyyy/MM/dd hh:mm:ss.SSS') // "2008/02/02 00:00:00.000" * format('2014/01/02/03/04/05/06', 'yyyy/MM/dd/hh/mm/ss', 'yyyy年MM月dd日 hh时mm分ss秒') // "2014年01月02日 03时04分05秒006毫秒" * * @param {Date|String} date Date 实例或日期字符串 * @param {String} [dateFormat='yyyy/MM/dd hh:mm:ss'] 转换格式 * * 常见格式为 yyyy[/-]MM[/-]dd hh:mm:ss.SSS, MM[/-]dd [/-]yyyy hh:mm:ss.SSS 及 ISO8601 时间格式。 * * 如果提供,则按具体格式严格匹配解析,并且年份必须为4位。 * - yyyy 代表年份 * - M 或 MM 代表1位或2位的月份 * - d 或 dd 代表1位或2位的天数 * - h 或 hh 代表24小时的1位或2位的小时 * - m 或 mm 代表1位或2位的分钟, * - s 或 ss 代表1位或2位的秒 * - S 或 SS 或 SSS 代表1位或2位或3位的毫秒 * * @returns {String} */ export declare const format: (date: any, dateFormat?: string) => any; /** * 将当前操作的时间变更时区,主要用于转换一个其他时区的时间。 * * var date = new Date(2017, 0, 1) * getDateWithNewTimezone(date, 0, -2) * * @param {Date} date Date 实例或日期字符串 * @param {Number} otz 原时区 -12~13 * @param {Number} ntz 目标时区 -12~13 默认为当前时区 * @param {Boolean} TimezoneOffset 时区偏移量 * @returns {Date} */ export declare const getDateWithNewTimezone: (date: any, otz: any, ntz: any, timezoneOffset?: number) => Date | undefined; /** * 按时区将 Date 实例转换成字符串。 * * toDateStr(new Date(2017, 0, 1, 12, 30), 'yyyy/MM/dd hh:mm', 3) // "2017/01/01 15:30" * toDateStr('2008/01/02', 'yyyy/MM/dd hh:mm', 3) // "2008/01/02 03:00" * * @param {Date|String} date Date 实例或日期字符串 * @param {String} dateFormat 转换格式 * @param {Number} [timezone] 时区 * @returns {String} */ export declare const toDateStr: (date: any, dateFormat: any, timezone: any) => any; /** * 获取日期所在周的第一天,默认周一为第一天(可扩展周日为第一天)。 * * getWeekOfFirstDay() // 返回当前日期所在周的周一同一时间 * getWeekOfFirstDay(true) // 返回当前日期所在周的周日同一时间 * getWeekOfFirstDay(new Date(2019, 8, 5)) // new Date(2019, 8, 2) * getWeekOfFirstDay(new Date(2019, 8, 5)), true) // new Date(2019, 8, 1) * * @param {Date} [date=new Date()] date 日期实例,默认当天 * @param {Boolean} [isSunFirst] 是否设置周日为第一天,非必填 * @returns {Date} */ export declare const getWeekOfFirstDay: (date: any, isSunFirst: any) => Date; export declare const getLocalTimezone: () => number; export declare const getStrTimezone: (value: any) => any;