wix-style-react
Version:
63 lines (54 loc) • 2.07 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _setDay = _interopRequireDefault(require("date-fns/setDay"));
var _format = _interopRequireDefault(require("date-fns/format"));
var _LocaleUtils = require("./LocaleUtils");
/**
* This file is used for backward compatibility.
* Since the `locale` prop allow passing `date-fns locale object` as value,
* we still need to support it and to keep this `localeUtils functions` that are based on the date-fns library!
*/
var WEEKDAY_SHORT = {
vi: 'iiiii'
};
var _default = function _default(locale, firstDayOfWeek) {
return {
formatMonthTitle: function formatMonthTitle(date) {
return (0, _LocaleUtils.capitalizeMonth)((0, _format["default"])(date, 'LLLL yyyy', {
locale: locale
}), locale);
},
formatWeekdayShort: function formatWeekdayShort(index) {
var shortWeekdayFormat = WEEKDAY_SHORT[locale] || 'iiiiii';
return (0, _format["default"])((0, _setDay["default"])(new Date(), index), shortWeekdayFormat, {
locale: locale
});
},
formatWeekdayLong: function formatWeekdayLong(index) {
return (0, _format["default"])((0, _setDay["default"])(new Date(), index), 'iiii', {
locale: locale
});
},
formatDay: function formatDay(date) {
return (0, _format["default"])(date, 'iii PP', {
locale: locale
});
},
getMonths: function getMonths() {
return _LocaleUtils.MONTHS_INDEXES.map(function (i) {
return (0, _LocaleUtils.capitalizeMonth)((0, _format["default"])(new Date(2018, i), 'LLLL', {
locale: locale
}), locale);
});
},
getFirstDayOfWeek: function getFirstDayOfWeek() {
var _ref;
return (_ref = firstDayOfWeek !== null && firstDayOfWeek !== void 0 ? firstDayOfWeek : _LocaleUtils.FIRST_WEEKDAY[locale]) !== null && _ref !== void 0 ? _ref : 1;
}
};
};
exports["default"] = _default;