本文整理汇总了TypeScript中moment.updateLocale函数的典型用法代码示例。如果您正苦于以下问题:TypeScript updateLocale函数的具体用法?TypeScript updateLocale怎么用?TypeScript updateLocale使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了updateLocale函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initMomentLocale
private initMomentLocale(lng: string) {
// Init the locale for the moment object (for date manipulations)
moment.locale(lng);
// 24h format
moment.updateLocale(lng, {
longDateFormat : i18n.t("longDateFormat", { returnObjects: true }),
});
}
示例2: loadLocale
export function loadLocale(locale: string) {
if (locale) {
let loc_mom = MOM_LOCALES[locale];
if (!loc_mom) {
return;
}
let keys = Object.keys(loc_mom);
let config = {};
keys.map(item => {
config[item.substring(1)] = loc_mom[item];
});
moment.updateLocale(locale, config);
}
}
示例3: moment
export const calculateFirstDateOfWeek: CalculateFirstDateOfWeekFn = (
currentDate, firstDayOfWeek, excludedDays = [],
) => {
const currentLocale = moment.locale();
moment.updateLocale('tmp-locale', {
week: { dow: firstDayOfWeek, doy: 1 }, // `doy` is required for TS using
});
const firstDateOfWeek = moment(currentDate as Date).startOf('week');
if (excludedDays.indexOf(firstDayOfWeek) !== -1) {
excludedDays.slice().sort().forEach((day) => {
if (day === firstDateOfWeek.day()) {
firstDateOfWeek.add(1, 'days');
}
});
}
moment.locale(currentLocale);
return firstDateOfWeek.toDate();
};
示例4: moment
// Fri Feb 27 2015 11:00:00 GMT+0000
moment('2015-02-28T16:00:00Z').subtractWorkingTime(5, 'hours');
// Fri Feb 27 2015 12:00:00 GMT+0000
moment('2015-02-27T16:00:00Z').subtractWorkingTime(5, 'hours', 30, 'minutes');
// Fri Feb 27 2015 10:30:00 GMT+0000
moment('2015-02-27T16:30:00Z').workingDiff(moment('2015-02-26T12:00:00Z'), 'hours');
// 12
moment('2015-02-27T16:30:00Z').workingDiff(moment('2015-02-26T12:00:00Z'), 'hours', true);
// 12.5
// set opening time to 09:30 and close early on Wednesdays
moment.updateLocale('en', {
workinghours: {
0: null,
1: ['09:30:00', '17:00:00'],
2: ['09:30:00', '17:00:00'],
3: ['09:30:00', '13:00:00'],
4: ['09:30:00', '17:00:00'],
5: ['09:30:00', '17:00:00'],
6: null
}
});
moment('2015-02-25T15:00:00Z').isWorkingTime(); // false
moment('2015-02-23T09:00:00Z').isWorkingTime(); // false
moment.updateLocale('en', {
holidays: [
'2015-05-04'
]
});
moment('2015-05-04T09:30:00Z').isWorkingDay(); // false
moment.updateLocale('en', {
holidays: [