react-moment icon indicating copy to clipboard operation
react-moment copied to clipboard

Including 'ago' with fromNow returns weird strings like 'a month'

Open burtonator opened this issue 6 years ago • 3 comments

When you include 'ago' with fromNow it includes an indefinite article ('a') before the time in some situations.

For "a month ago" it will generate "a month" which is really weird.

It should probably be more like "1 month"..

burtonator avatar Nov 22 '18 20:11 burtonator

In fact it might be nice to have this as a property. I can see people wanting to just use "1 month ago" instead of "a month ago" or "1 minute ago" instead of "a minute ago"

burtonator avatar Nov 22 '18 20:11 burtonator

This is a valid workaround:

filter={(value) => value.replace(/^a /g, '1 ')}

but probably only works for en-US locale

burtonator avatar Nov 22 '18 20:11 burtonator

At least in English, "a/an" is a common way to denote one, i.e. "I have an apple," or "I sent you this a year ago!"

That being said, having an option to use digits/numbers to be more precise wouldn't hurt, although this might be out of scope for this package.

bleonard252 avatar Aug 17 '22 18:08 bleonard252