mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 15:48:42 +00:00
46 lines
1.4 KiB
JavaScript
Generated
46 lines
1.4 KiB
JavaScript
Generated
/* eslint-disable */
|
|
|
|
/**
|
|
* @typedef {"year" | "years" | "quarter" | "quarters" | "month" | "months" | "week" | "weeks" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds"} RelativeTimeFormatUnit
|
|
*/
|
|
|
|
/**
|
|
* @param {import("./runtime.js").Locale} locale
|
|
* @param {unknown} input
|
|
* @param {Intl.PluralRulesOptions} [options]
|
|
* @returns {string}
|
|
*/
|
|
export function plural(locale, input, options) {
|
|
return new Intl.PluralRules(locale, options).select(Number(input))
|
|
};
|
|
|
|
/**
|
|
* @param {import("./runtime.js").Locale} locale
|
|
* @param {unknown} input
|
|
* @param {Intl.NumberFormatOptions} [options]
|
|
* @returns {string}
|
|
*/
|
|
export function number(locale, input, options) {
|
|
return new Intl.NumberFormat(locale, options).format(Number(input))
|
|
};
|
|
|
|
/**
|
|
* @param {import("./runtime.js").Locale} locale
|
|
* @param {unknown} input
|
|
* @param {Intl.DateTimeFormatOptions} [options]
|
|
* @returns {string}
|
|
*/
|
|
export function datetime(locale, input, options) {
|
|
return new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input)))
|
|
};
|
|
|
|
/**
|
|
* @param {import("./runtime.js").Locale} locale
|
|
* @param {unknown} input
|
|
* @param {Intl.RelativeTimeFormatOptions & { unit: RelativeTimeFormatUnit }} options
|
|
* @returns {string}
|
|
*/
|
|
export function relativetime(locale, input, options) {
|
|
const { unit, ...intlOptions } = options;
|
|
return new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit);
|
|
}; |