本文整理汇总了TypeScript中moment.weekdays函数的典型用法代码示例。如果您正苦于以下问题:TypeScript weekdays函数的具体用法?TypeScript weekdays怎么用?TypeScript weekdays使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了weekdays函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: moment
.config(($mdDateLocaleProvider: angular.material.IDateLocaleProvider) => {
$mdDateLocaleProvider.parseDate = (dateString: string) => {
console.log(dateString);
let m = moment(dateString, 'DD.MM.YYYY', true);
return m.isValid() ? m.utc().toDate() : new Date(NaN);
};
$mdDateLocaleProvider.formatDate = (date: Date) => {
if (date === undefined || date === null)
return null;
return moment(date).format('DD.MM.YYYY');
};
$mdDateLocaleProvider.months = moment.months();
$mdDateLocaleProvider.shortMonths = moment.monthsShort();
$mdDateLocaleProvider.days = moment.weekdays();
$mdDateLocaleProvider.shortDays = moment.weekdaysShort();
$mdDateLocaleProvider.firstDayOfWeek = 1;
})
示例2:
const getWeekDays = () => moment.weekdays().map((day: string, i: number) => localeDate.clone().startOf('week').add(i, 'day').format('dd'));
示例3: Promise
return new Promise(resolve => {
let date = moment(cordysDate, 'YYYY/MM/DDTHH:mm:ss.SSS');
if (cordysDate.indexOf('T') < 0) {
date = moment(cordysDate, 'YYYY/MM/DD HH:mm:ss');
}
// clone date and set 12:00 am
let dateWithoutTime = moment(date).startOf('day');
// today 12:00 am
let nowWithoutTime = moment().startOf('day');
// after today 12:00 am
if (nowWithoutTime.isSame(dateWithoutTime)) {
if (hideTime) {
this.translate.get('app.date.today').subscribe(message => {
resolve(message);
});
} else {
resolve(date.fromNow());
}
}
// after yesterday 12:00 am
// 昨日 12:00 / 昨天 12:00 / Yesterday 12:00
if (moment(nowWithoutTime).subtract(1, 'days').isSame(dateWithoutTime)) {
this.translate.get('app.date.yesterday').subscribe(message => {
if (hideTime) {
resolve(message);
} else {
resolve(message + date.format('H:mm'));
}
});
}
// yesterday 12:00am ~ last week 12:00 am
// X曜日 / 星期X / Mon.
if (moment(nowWithoutTime).subtract(1, 'days').isAfter(dateWithoutTime) &&
(moment(nowWithoutTime).subtract(7, 'days').isSame(dateWithoutTime) ||
moment(nowWithoutTime).subtract(7, 'days').isBefore(dateWithoutTime))) {
resolve(moment.weekdays(date.day()));
}
// 182days(half of a year) before 12:00am ~ last week 12:00 am
// M月d日 / M月d日 / Mnd/d
if (moment(nowWithoutTime).subtract(7, 'days').isAfter(dateWithoutTime) &&
(moment(nowWithoutTime).subtract(182, 'days').isSame(dateWithoutTime) ||
moment(nowWithoutTime).subtract(182, 'days').isBefore(dateWithoutTime))) {
let parameter = {
'MM': (date.month() + 1),
'DD': date.date()
};
this.translate.get('app.date.MMDD', parameter).subscribe(message => {
resolve(message);
});
}
// 183days before 12:00am
if (moment(nowWithoutTime).subtract(182, 'days').isAfter(dateWithoutTime)) {
let parameter = {
'YYYY': date.year(),
'MM': (date.month() + 1)
};
this.translate.get('app.date.YYYYMM', parameter).subscribe(message => {
resolve(message);
});
}
});
示例4: weekdays
public weekdays(number): string {
return moment.weekdays(number);
}
示例5: getWeekday
getWeekday(dateString: string) {
return moment.weekdays(moment(dateString).day());
}