@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
69 lines (68 loc) • 2.25 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var utils_exports = {};
__export(utils_exports, {
getFormat: () => getFormat,
getOrderWithFormat: () => getOrderWithFormat,
getSeparator: () => getSeparator
});
module.exports = __toCommonJS(utils_exports);
function getSeparator(locale) {
const formatter = new Intl.DateTimeFormat(locale);
const parts = formatter.formatToParts(new Date(2e3, 1, 2));
const { value } = parts.find((part) => {
if (part.type === "literal")
return true;
return false;
});
return value;
}
function getFormat(locale) {
const formatter = new Intl.DateTimeFormat(locale);
const parts = formatter.formatToParts(new Date(2e3, 1, 2));
const format = parts.map((part) => {
if (part.type === "day")
return "dd";
if (part.type === "month")
return "mm";
if (part.type === "year")
return "yyyy";
return "-";
}).join("");
return format;
}
function getOrderWithFormat(locale, format) {
const localeFormat = getFormat(locale);
const formatArray = format.split("-");
const localeFormatArray = localeFormat.split("-");
const result = [];
formatArray.forEach((item) => {
const index = localeFormatArray.findIndex((e) => item === e);
if (index === -1)
return;
result[index] = item;
});
return result.filter(Boolean);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getFormat,
getOrderWithFormat,
getSeparator
});
//# sourceMappingURL=utils.js.map