本文整理汇总了TypeScript中moment/moment.moment函数的典型用法代码示例。如果您正苦于以下问题:TypeScript moment函数的具体用法?TypeScript moment怎么用?TypeScript moment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了moment函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: transform
transform(timeEnd: string, timeStart: string): string {
if(!timeEnd || !timeStart) {
return 'unknown';
}
let start = moment(timeStart);
let end = moment(timeEnd);
let diff = end.diff(start, 'minutes');
if (diff < 1) {
return '< 1 minute';
} else if (diff == 1) {
return '1 minute';
} else if (diff < 60) {
return `${diff} minutes`;
}
diff = end.diff(start, 'hours');
if (diff === 1) {
return '1 hour';
} else if (diff < 24) {
return `${diff} hours`;
}
diff = end.diff(start, 'days');
if (diff === 1) {
return '1 day';
}
return `${diff} days`;
}
开发者ID:tmolteno,项目名称:TART,代码行数:28,代码来源:time-elapsed-pipe.ts
示例2: onModeChanged
onModeChanged(newMode: Number) {
this.calendarMode = newMode;
switch (this.calendarMode) {
case 1:
this.currentDate = this.currentDate.clone().startOf('month');
break;
case 2:
this.currentDate = this.currentDate.clone().startOf('week');
break;
case 3:
let firstMonthDiff = moment().diff(this.currentDate.startOf('week'), 'months');
let secondMonthDiff = moment().diff(this.currentDate.endOf('week'), 'months');
if (firstMonthDiff !== secondMonthDiff) {
if (firstMonthDiff < secondMonthDiff && firstMonthDiff >= 0) {
this.currentDate = moment().add(firstMonthDiff, 'months');
} else {
this.currentDate = moment().add(secondMonthDiff, 'months');
}
} else {
this.currentDate = this.currentDate.clone().startOf('month');
}
break;
default:
this.currentDate = this.currentDate.clone().startOf('month');
break;
}
}
开发者ID:waffle-iron,项目名称:teki,代码行数:27,代码来源:schedular.ts
示例3: constructor
constructor(req: IRequestState) {
this.id = req.id;
this.state = ViewRequestStates[req.status];
this.pickUpTime = moment(req.pickUpTime);
this.lineId = req.lineId;
this.acceptingBus = req.acceptingBus;
}
开发者ID:mzeen,项目名称:SS2016-group2,代码行数:7,代码来源:ViewRequestState.ts
示例4: transform
public transform(timestampMicros: number): any {
if (!timestampMicros) {
return '';
}
moment.locale(I18n.language);
return moment(timestampMicros).format('LLL');
}
开发者ID:mdharamadas1,项目名称:admiral,代码行数:7,代码来源:locale-date.pipe.ts
示例5: transform
transform(value: any): any {
if (isNaN(value)) {
return '';
}
return moment(new Date(value)).fromNow();
}
开发者ID:iraghumitra,项目名称:incubator-metron,代码行数:7,代码来源:time-lapse.pipe.ts
示例6: it
it('end date is invalid if it is in the future', () => {
expect(component.filterForm.get('endTime').valid).toBe(true);
component.filterForm.patchValue({
endTime: moment(new Date()).add(2, 'days').format(DEFAULT_TIMESTAMP_FORMAT)
});
expect(component.filterForm.get('endTime').valid).toBe(false);
});
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:10,代码来源:pcap-filters.component.spec.ts
示例7: isPublishedDate
export function isPublishedDate(start, end, format="YYYY-MM-DD")
{
let info = {result: false, publishedStart: "", publishedEnd: "", code: 0};
let s = void 0 === start ? null : moment(start);
let e = void 0 === end || !moment(end).isValid() ? null : moment(end);
//バリデーションチェック
if (null === s || !s.isValid()) { info.code = 1; return info;}
info.publishedStart = s.format(format);
if (null === e)
{
info.publishedEnd = null;
}
else
{
if (!e.isValid()) { info.code = 1; return info; }
if (s.isAfter(e)) { info.code = 2; return info; }
info.publishedEnd = e.format(format);
}
info.result = true;
return info;
}
开发者ID:gozaru9,项目名称:new-river-fatman,代码行数:22,代码来源:common.ts
示例8: parseDate
parseDate(inputString: string): Date {
return moment(inputString, "DD.MM.YYYY HH:mm").toDate();
}
开发者ID:dominikmathmann,项目名称:ngTime,代码行数:3,代码来源:date.directive_1.ts
示例9: formatDate
formatDate(inputDate: Date): string {
return moment(inputDate).format("DD.MM.YYYY HH:mm")
}
开发者ID:dominikmathmann,项目名称:ngTime,代码行数:4,代码来源:date.directive_1.ts
示例10: saveConference
saveConference(currentConference: Conference): Observable<Conference> {
currentConference.startDate = Moment(currentConference.startDateStr).utc().toDate();
currentConference.endDate = Moment(currentConference.endDateStr).utc().toDate();
return this.onSaveConference(currentConference);
}
开发者ID:rightincode,项目名称:speakerregister,代码行数:7,代码来源:conference.service.ts
注:本文中的moment/moment.moment函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论