本文整理匯總了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());
}