当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Moment.diff方法代码示例

本文整理汇总了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);
    }
开发者ID:beele,项目名称:WeatherGenieV2-Frontend,代码行数:15,代码来源:sun-tile.component.ts

示例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
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:9,代码来源:calculateInterest.ts

示例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()
}
开发者ID:rymizuki,项目名称:site-animechannel,代码行数:18,代码来源:period.ts

示例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
  };

};
开发者ID:xMrWhite,项目名称:calendar-utils,代码行数:38,代码来源:calendarUtils.ts

示例5: remainingDays

 get remainingDays (): number {
   return this.responseDeadline.diff(MomentFactory.currentDate(), 'days')
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:3,代码来源:claim.ts

示例6: diff

 public diff(other: ImmutableMoment): number {
   const diff = this.moment.diff(other.moment)
   return diff
 }
开发者ID:janaagaard75,项目名称:FilmFilter,代码行数:4,代码来源:ImmutableMoment.ts


注:本文中的moment.Moment.diff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。