當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript moment.updateLocale函數代碼示例

本文整理匯總了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 }),
        });
    }
開發者ID:ScoutmanPt,項目名稱:PnP,代碼行數:10,代碼來源:LocalizationModule.ts

示例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);
  }
}
開發者ID:gatsbimantico,項目名稱:ontimize-web-ngx,代碼行數:14,代碼來源:locales.ts

示例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();
};
開發者ID:MaximKudriavtsev,項目名稱:devextreme-reactive,代碼行數:19,代碼來源:utils.ts

示例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: [
開發者ID:AdaskoTheBeAsT,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:moment-business-time-tests.ts


注:本文中的moment.updateLocale函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。