本文整理汇总了TypeScript中dayjs类的典型用法代码示例。如果您正苦于以下问题:TypeScript dayjs类的具体用法?TypeScript dayjs怎么用?TypeScript dayjs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dayjs类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toFormatter
export function toFormatter(date: Date): DateFormatter {
const wrappedDate = dayjs(date);
return {
fromNow: () => wrappedDate.fromNow(),
format: (format: string) => wrappedDate.format(format)
};
}
示例2: dayjs
gulp.task('clean:version-lib', (next) => {
const v = npmconfig.version;
const b = dayjs().startOf('m').valueOf();
return gulp.src(['./lib/src/composer.module.ts']) // Any file globs are supported
.pipe(replace(/public static version = '[0-9a-zA-Z.-]*'/g, `public static version = 'local-dev'`, { logs: { enabled: true } }))
.pipe(replace(/private build = dayjs\([0-9]*\);/g, `private build = dayjs();`, { logs: { enabled: true } }))
.pipe(gulp.dest('./lib/src'));
});
示例3: dayjs
export const downloadJSON = (panelName, modelName, endpoint) => {
const timestamp = dayjs(Date.now()).format('DD_MM_YYYY_HH_mm_ss');
return api.get(endpoint).then((res) => {
const content = JSON.stringify(res.data, null, 2);
const a = document.createElement('a');
const file = new Blob([content]);
a.href = URL.createObjectURL(file);
a.download = `${modelName}_${timestamp}_${panelName}.json`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
});
};
示例4: reviver
export function reviver(key, value) {
if (typeof value === 'string')
if (ISO8601Regex.exec(value))
return dayjs(value).toDate();
return value;
}
示例5: replacer
export function replacer(key, value) {
if (typeof value === 'string')
if (ISO8601Regex.exec(value))
return dayjs(value).format("YYYY-MM-DDTHH:mm:ss.SSSZ");
return value;
}
示例6: getFormatter
export function getFormatter(date: Date): DateFormatter {
return dayjs(date);
}