conventional-changelog/conventional-changelog

Misuse of Swedish Locale (conventional-changelog-writer/src/utils.ts)

srl295 opened this issue · 0 comments

Code at

* Formats date to yyyy-mm-dd format.
* @param date - Date string, number or Date object.
* @param timeZone - Time zone to use.
* @returns Date string in yyyy-mm-dd format.
*/
export function formatDate(date?: string | number | Date, timeZone = 'UTC') {
const dateFormatter = !timeZone || timeZone === 'UTC'
? utcDateFormatter
: Intl.DateTimeFormat('sv-SE', {
timeZone
})
// sv-SEis used for yyyy-mm-dd format
return dateFormatter.format(date ? new Date(date) : new Date())
}
(#1162) misuses the Swedish locale for non-internationalization purposes. Don't do that if you expect identical behavior, locale data can and does change.

Better would be to take the user's locale and use it, if the output is for humans, or format some other way.

Referenced from nodejs/node#51090