mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-20 01:13:47 +05:00
refactor(helpers): refactor printDate func
This commit is contained in:
parent
26b33e3298
commit
b5f20894c3
1 changed files with 3 additions and 7 deletions
|
@ -68,16 +68,12 @@ export function randomNum(min = 0, max = 100) {
|
||||||
/**
|
/**
|
||||||
* Formats a date for the specified client and locale.
|
* Formats a date for the specified client and locale.
|
||||||
*
|
*
|
||||||
* @param {Object} client - The client object containing language data.
|
|
||||||
* @param {string} date - The date to format.
|
* @param {string} date - The date to format.
|
||||||
* @param {string} [format=null] - The date format to use. If not provided, the default format for the client's language will be used.
|
* @param {Intl.LocalesArgument} [locale] - The locale to use for formatting the date.
|
||||||
* @param {string} [locale=client.defaultLanguage.name] - The locale to use for formatting the date.
|
|
||||||
* @returns {string} The formatted date.
|
* @returns {string} The formatted date.
|
||||||
*/
|
*/
|
||||||
export function printDate(client, date, format = null, locale = client.defaultLanguage.name) {
|
export function printDate(date, locale = "en-US") {
|
||||||
const { format: languageFormat, locale: localeFormat } = client.languages.find(language => language.name === locale);
|
return new Intl.DateTimeFormat(locale).format(date);
|
||||||
if (format === "" || format === null) format = languageFormat;
|
|
||||||
return new Intl.DateTimeFormat(localeFormat).format(date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue