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


TypeScript moment.Moment类代码示例

本文整理汇总了TypeScript中moment.Moment的典型用法代码示例。如果您正苦于以下问题:TypeScript Moment类的具体用法?TypeScript Moment怎么用?TypeScript Moment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Moment类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setFirstPaymentDate

 function setFirstPaymentDate (firstPaymentDate: Moment): object {
   return {
     day: firstPaymentDate.date(),
     month: firstPaymentDate.month() + 1,
     year: firstPaymentDate.year()
   }
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:7,代码来源:payment-plan.ts

示例2: it

 it('should render page with error when DOB is less than 18', async () => {
   draftStoreServiceMock.resolveFind('claim')
   const date: Moment = MomentFactory.currentDate().subtract(1, 'year')
   await request(app)
     .post(ClaimPaths.claimantDateOfBirthPage.uri)
     .set('Cookie', `${cookieName}=ABC`)
     .send({ known: 'true', date: { day: date.date(), month: date.month() + 1, year: date.year() } })
     .expect(res => expect(res).to.be.successful.withText('Please enter a date of birth before', 'div class="error-summary"'))
 })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:9,代码来源:claimant-dob.ts

示例3: removeHoursAndMinutes

  private static removeHoursAndMinutes(dateTime: Moment): Moment {
    const date = moment(new Date(
      dateTime.year(),
      dateTime.month(),
      dateTime.date()
    ))

    return date
  }
开发者ID:janaagaard75,项目名称:FilmFilter,代码行数:9,代码来源:ImmutableDate.ts

示例4: String

 const getFromDate = (date: Moment): Semester => {
   const prefix = date.month() >= 6 ? 'h' : 'v'
   const suffix = String(date.year()).slice(2, 4)
   return {
     id: prefix + suffix,
     year: date.year(),
     semester: prefix,
   }
 }
开发者ID:blindern,项目名称:intern,代码行数:9,代码来源:ArrplanService.ts

示例5: moment

export const getWeekViewHeader: Function = ({viewDate}: {viewDate: Date}): WeekDay[] => {

  const start: Moment = moment(viewDate).startOf('week');
  const days: WeekDay[] = [];
  for (let i: number = 0; i < DAYS_IN_WEEK; i++) {
    const date: Moment = start.clone().add(i, 'days');
    days.push(getWeekDay({date}));
  }

  return days;

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

示例6: dataToSend

 function dataToSend (firstPaymentDate: Moment): object {
   return {
     totalAmount: 100,
     instalmentAmount: 50,
     firstPaymentDate: {
       day: firstPaymentDate.date(),
       month: firstPaymentDate.month() + 1,
       year: firstPaymentDate.year()
     },
     paymentSchedule: 'EVERY_MONTH'
   }
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:12,代码来源:payment-plan.ts

示例7: decade

export function decade(date: Moment): Moment[] {
    if (!date || !date.isValid()) {
        throw new Error("Date is not valid");
    }

    const year = date.year();
    const startYear = year - year % 10;
    const endYear = startYear + 9;

    return [
        date.clone().year(startYear),
        date.clone().year(endYear)
    ];
}
开发者ID:Nimzi-Git,项目名称:angular-io-datepicker,代码行数:14,代码来源:dateUtils.ts

示例8: momentsEqual

function momentsEqual(x: Moment, y: Moment, isTime: boolean): boolean {
  if (!isTime) {
    return x.isSame(y);
  }
  return (
    x.hour() === y.hour() &&
    x.minute() === y.minute() &&
    x.second() === y.second() &&
    x.millisecond() === y.millisecond()
  );
}
开发者ID:nrkn,项目名称:quicktype,代码行数:11,代码来源:deepEquals.ts

示例9: 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


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