From b5f20894c362a1c0b78ab83038f2eec7f3e82790 Mon Sep 17 00:00:00 2001 From: Slincnik Date: Tue, 7 Jan 2025 19:37:52 +0300 Subject: [PATCH] refactor(helpers): refactor printDate func --- src/helpers/functions.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/helpers/functions.js b/src/helpers/functions.js index 0b435883..2158db5b 100644 --- a/src/helpers/functions.js +++ b/src/helpers/functions.js @@ -68,16 +68,12 @@ export function randomNum(min = 0, max = 100) { /** * 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} [format=null] - The date format to use. If not provided, the default format for the client's language will be used. - * @param {string} [locale=client.defaultLanguage.name] - The locale to use for formatting the date. + * @param {Intl.LocalesArgument} [locale] - The locale to use for formatting the date. * @returns {string} The formatted date. */ -export function printDate(client, date, format = null, locale = client.defaultLanguage.name) { - const { format: languageFormat, locale: localeFormat } = client.languages.find(language => language.name === locale); - if (format === "" || format === null) format = languageFormat; - return new Intl.DateTimeFormat(localeFormat).format(date); +export function printDate(date, locale = "en-US") { + return new Intl.DateTimeFormat(locale).format(date); } /**