本文整理汇总了TypeScript中date-fns/parse.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: tap
tap(() => {
if (app.application.status && app.application.status.dataPreviewEndpoint && app.mostRecentData) {
const defaultUntil = parse(app.mostRecentData);
const defaultSince = subMonths(startOfDay(defaultUntil), 1);
this.dataPreview$ = this.hatAppSvc.getApplicationData(
app.application.status.dataPreviewEndpoint,
format(defaultSince, 'X'),
format(defaultUntil, 'X')
);
} else {
this.dataPreview$ = of([]);
}
}),
示例2: getTimeDistance
export function getTimeDistance(
type:
| 'today'
| '-today'
| 'week'
| '-week'
| 'month'
| '-month'
| 'year'
| '-year'
| number,
time?: Date | string | number,
): [Date, Date] {
time = parse(time || new Date());
switch (type) {
case 'today':
case '-today':
return [time, time];
case 'week':
return [startOfWeek(time), endOfWeek(time)];
case '-week':
return [startOfWeek(subWeeks(time, 1)), endOfWeek(subWeeks(time, 1))];
case 'month':
return [startOfMonth(time), endOfMonth(time)];
case '-month':
return [startOfMonth(subMonths(time, 1)), endOfMonth(subMonths(time, 1))];
case 'year':
return [startOfYear(time), endOfYear(time)];
case '-year':
return [startOfYear(subYears(time, 1)), endOfYear(subYears(time, 1))];
default:
return type > 0
? [time, addDays(time, type)]
: [addDays(time, type), time];
}
}
示例3: transform
transform(date: string | number | Date, to: string = 'YYYY-MM-DDTHH:mm:ssZ'): string {
const nativeDate = parse(date);
return format(nativeDate, to);
}
示例4: parseDate
export function parseDate(rawDate: ParsableDate): Date {
return parse(rawDate);
}