本文整理匯總了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()
}
}
示例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"'))
})
示例3: removeHoursAndMinutes
private static removeHoursAndMinutes(dateTime: Moment): Moment {
const date = moment(new Date(
dateTime.year(),
dateTime.month(),
dateTime.date()
))
return date
}
示例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,
}
}
示例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;
};
示例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'
}
}
示例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)
];
}
示例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()
);
}
示例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);
}