當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。