本文整理匯總了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: [