本文整理汇总了TypeScript中moment/moment.Moment类的典型用法代码示例。如果您正苦于以下问题:TypeScript Moment类的具体用法?TypeScript Moment怎么用?TypeScript Moment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Moment类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('MomentPipe', () => {
let defaultFormat: string;
let nowMoment: Moment;
let pipe = new MomentPipe();
beforeEach(() => {
defaultFormat = 'MMM DD, YYYY';
nowMoment = moment();
});
it('should transform "nowMoment" to a string formatted as defaultFormat', () => {
expect(pipe.transform(nowMoment)).toBe(nowMoment.format(defaultFormat));
});
it('should transform "nowMoment" to a string formatted as a provided format', () => {
let providedFormat = "dddd, MMMM Do YYYY, h:mm:ss a";
expect(pipe.transform(nowMoment, providedFormat)).toBe(nowMoment.format(providedFormat));
})
});
示例2: transform
transform( moment: Moment, format?: string ): string {
return format ? moment.format(format) : moment.format('MMM DD, YYYY');
}
示例3: it
it('should transform "nowMoment" to a string formatted as a provided format', () => {
let providedFormat = "dddd, MMMM Do YYYY, h:mm:ss a";
expect(pipe.transform(nowMoment, providedFormat)).toBe(nowMoment.format(providedFormat));
})