本文整理汇总了TypeScript中date-fns/format.format函数的典型用法代码示例。如果您正苦于以下问题:TypeScript format函数的具体用法?TypeScript format怎么用?TypeScript format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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([]);
}
}),
开发者ID:Hub-of-all-Things,项目名称:Rumpel,代码行数:14,代码来源:hat-application-details.component.ts
示例2: function
return function(day: Date): VNode {
const dayEnd = addDays(day, 1);
const tours = ctrl.data.tournaments.filter(t =>
t.bounds.start < dayEnd && t.bounds.end > day
);
return h('day', [
h('date', {
attrs: {
title: format(day, 'dddd, DD/MM/YYYY')
}
}, [format(day, 'DD/MM')]),
h('lanes', makeLanes(tours).map(l => renderLane(ctrl, l, day)))
]);
};
开发者ID:ddugovic,项目名称:lila,代码行数:14,代码来源:view.ts
示例3: transform
transform(
value: Date | string | number,
formatString: string = 'YYYY-MM-DD HH:mm',
): string {
if (value) {
if (formatString === 'fn') {
return distanceInWordsToNow(value, {
locale: (window as any).__locale__,
});
}
return format(value, formatString);
} else {
return '';
}
}
开发者ID:wexz,项目名称:delon,代码行数:15,代码来源:date.pipe.ts
示例4: ngAfterViewInit
ngAfterViewInit() {
const today = format(new Date(), 'ddd DD MMM YYYY');
this.dateSeparators.changes.pipe(take(1)).subscribe((changes) => {
const todayElement = changes.find(item => {
return item.nativeElement.textContent === today;
});
// TODO: Fix this hack. Material mat-sidenav component does not currently support programmatic scrolling
// See https://github.com/angular/material2/issues/4280
if (todayElement) {
document.querySelector('.mat-sidenav-content').scrollTop = todayElement.nativeElement.offsetTop;
}
});
}
开发者ID:Hub-of-all-Things,项目名称:Rumpel,代码行数:15,代码来源:she-feed.component.ts
示例5: async
export const getCourses = async (
restaurantId: number,
day: Date,
lang: Lang
): Promise<CourseType[]> => {
const restaurant = await http.get(
`/restaurants/${restaurantId}/menu?day=${format(
day,
'YYYY-MM-DD'
)}&lang=${lang}`
);
if (!restaurant.menus.length) {
return [];
} else {
return restaurant.menus[0].courses;
}
};
开发者ID:Kanttiinit,项目名称:kanttiinit-web,代码行数:17,代码来源:api.ts
示例6: renderTournament
function renderTournament(ctrl: Ctrl, tour: Tournament, day: Date) {
const paddingLeft = 0;
let left = (getHours(tour.bounds.start) + getMinutes(tour.bounds.start) / 60) / 24 * 100;
if (tour.bounds.start < day) left -= 100;
const width = tour.minutes / 60 / 24 * 100;
return h('a.tournament', {
class: tournamentClass(tour, day),
attrs: {
href: '/tournament/' + tour.id,
style: 'width: ' + width + '%; left: ' + left + '%',
title: `${tour.fullName} - ${format(tour.bounds.start, 'dddd, DD/MM/YYYY HH:mm')}`
}
}, [
h('span.icon', tour.perf ? {
attrs: {
'data-icon': iconOf(tour, tour.perf.icon)
}
} : {}),
h('span.body', [ tour.fullName ])
]);
}
开发者ID:ddugovic,项目名称:lila,代码行数:22,代码来源:view.ts
示例7: format
import * as format from 'date-fns/format'
const result = format('2017-01-25T21:28:15.000Z', 'DD.MM.YYYY HH:mm:ss')
console.log(result === '25.01.2017 21:28:15')
开发者ID:mrenty,项目名称:date-fns,代码行数:4,代码来源:misc.ts
示例8: transform
transform(date: string | number | Date, to: string = 'YYYY-MM-DDTHH:mm:ssZ'): string {
const nativeDate = parse(date);
return format(nativeDate, to);
}
开发者ID:Hub-of-all-Things,项目名称:Rumpel,代码行数:5,代码来源:datetime.pipe.ts
示例9: format
.map(day => format(day, 'YYYY-MM-DD'))
开发者ID:Kanttiinit,项目名称:kanttiinit-web,代码行数:1,代码来源:api.ts
示例10: it
it('should be now when a bad date', () => {
const ret = getTimeDistance('-today', -NaN);
expect(ret.length).toBe(2);
expect(format(ret[0], FORMAT)).toBe(format(new Date(), FORMAT));
expect(format(ret[1], FORMAT)).toBe(format(new Date(), FORMAT));
});
开发者ID:wexz,项目名称:delon,代码行数:6,代码来源:time.spec.ts
注:本文中的date-fns/format.format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论