date-fns / date-fns.org

🏡 date-fns website 🌈
https://date-fns.org
MIT License
55 stars 32 forks source link

Update home page examples to more accurately reflect output #142

Closed spencerbyw closed 3 years ago

spencerbyw commented 5 years ago

I noticed on the home page the examples aren't exactly portraying what the correct output should be: image

I did a bit of testing to see what the actual output is supposed to be:

> formatDistance(subDays(new Date(), 3), new Date())
'3 days'
> formatDistance(subDays(new Date(), 3), new Date(), { addSuffix: true })
'3 days ago'
> formatRelative(subDays(new Date(), 3), new Date())
'last Sunday at 7:43 PM'

So the two changes I made are:

  1. In order to display the ago text at the end, formatDistance needs { addSuffix: true }. Another possible solve is to just remove the ago text in the comment. I can change that if desired, just let me know.
  2. formatRelative doesn't display p.m., it displays PM.
spencerbyw commented 5 years ago

@kossnocorp Appears that CI failed, but looking at the last PR that was merged it seems like this is ok?

dkozickis commented 4 years ago

Paging @kossnocorp