date-fns icon indicating copy to clipboard operation
date-fns copied to clipboard

Remove non-standard wordMapping in formatDistance for nn and sv locales

Open cupofjoakim opened this issue 1 year ago • 8 comments

Today norwegian nynorsk (nn) and swedish (sv) replaces numbers under 13 with words. As far as I can tell, they are the only locales that do so. The other big norwegian dialect (nb) does not do it. I tried looking at the git history and it seems the word mapping has been here a long time and just hasn't been questioned.

As a swedish man who grew up on the border to norway, I propose that we leave this behind. I don't find the formatDistance behaviour problematic when used in isolation, but considering its' use in formatDuration, it gets a bit more iffy:

// given 
formatDuration(duration, {delimiter: ', ', locale})
// now
// `15 dagar, fyra timmar, tio minuter, 15 sekunder`
// after
// `15 dagar, 4 timmar, 10 minuter, 15 sekunder`

Earlier the option onlyNumeric existed for sv and nn to bring about this behaviour, but it was undocumented and removed in v3.0.0: https://github.com/date-fns/date-fns/releases/tag/v3.0.0

Addresses #3805 and (i believe) #3188

cupofjoakim avatar May 31 '24 13:05 cupofjoakim