本文整理汇总了TypeScript中moment.Moment.diff方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Moment.diff方法的具体用法?TypeScript Moment.diff怎么用?TypeScript Moment.diff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moment.Moment
的用法示例。
在下文中一共展示了Moment.diff方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnChanges
ngOnChanges() {
this.updateSunPosition(-100);
const sunrise: Moment = moment(this.tileData.sunrise);
const sunset: Moment = moment(this.tileData.sunset);
const nowTime: Moment = moment().utc();
const minutesBetweenSunriseAndSunset = sunset.diff(sunrise, 'minutes', true);
const minutesBetweenSunriseAndNow = nowTime.diff(sunrise, 'minutes', true);
const solarProgressionInDegrees = Math.round((minutesBetweenSunriseAndNow / minutesBetweenSunriseAndSunset) * 180);
this.angle = solarProgressionInDegrees - 100;
setTimeout(() => {
this.updateSunPosition();
}, 10);
}
示例2: calculateInterest
export async function calculateInterest (amount: number,
interestRate: number,
interestFromDate: Moment,
interestToDate: Moment = MomentFactory.currentDateTime()): Promise<number> {
if (interestToDate.diff(interestFromDate, 'days') > 0) {
return InterestRateClient.calculateInterestRate(amount, interestRate, interestFromDate, interestToDate)
}
return 0
}
示例3: periodToDateList
export function periodToDateList (fromStr: string, toStr: string, { holiday }: { holiday: Boolean }) {
const from: Moment = moment(fromStr)
const to: Moment = moment(toStr)
const diff = Math.ceil(to.diff(from, 'day', true))
return chain(diff)
.times()
.map((index) => from.clone().add(index, 'days'))
.filter((date) => {
if (holiday) return true // 休日を含むなら常にtrue
if (date.isoWeekday() == 6) return false // 土曜日はfalse
if (date.isoWeekday() == 7) return false // 日曜日はfalse
return true // FIXME: 祝日
})
.map((date) => date)
.value()
}
示例4: moment
export const getMonthView: Function = ({events, viewDate}: {events: CalendarEvent[], viewDate: Date}): MonthView => {
const start: Moment = moment(viewDate).startOf('month').startOf('week');
const end: Moment = moment(viewDate).endOf('month').endOf('week');
const eventsInMonth: CalendarEvent[] = getEventsInPeriod({
events,
periodStart: moment(viewDate).startOf('month'),
periodEnd: moment(viewDate).endOf('month')
});
const days: MonthViewDay[] = [];
for (let i: number = 0; i < end.diff(start, 'days') + 1; i++) {
const date: Moment = start.clone().add(i, 'days');
const day: MonthViewDay = getWeekDay({date});
day.inMonth = date.clone().startOf('month').isSame(moment(viewDate).startOf('month'));
if (day.inMonth) {
day.events = getEventsInPeriod({
events: eventsInMonth,
periodStart: moment(date).startOf('day'),
periodEnd: moment(date).endOf('day')
});
} else {
day.events = [];
}
days.push(day);
}
const rows: number = Math.floor(days.length / 7);
const rowOffsets: number[] = [];
for (let i: number = 0; i < rows; i++) {
rowOffsets.push(i * 7);
}
return {
rowOffsets,
days
};
};
示例5: remainingDays
get remainingDays (): number {
return this.responseDeadline.diff(MomentFactory.currentDate(), 'days')
}
示例6: diff
public diff(other: ImmutableMoment): number {
const diff = this.moment.diff(other.moment)
return diff
}