You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just spent a bit of time scratching my head about a unit test failure the other day, and assumed that it had something to do with leap-year. Instead, it looks like February is not considered "about a month":
import{formatDistanceToNow,sub}from'date-fns';console.log(formatDistanceToNow(sub(newDate(),{months: 1})));// Called on any month besides March:// "about one month"// Called during the month of March:// "29 days"
The above happens because one month ago from a day in March will be 28/29 days, which is less than the cutoff for "about one month" which is:
29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs
Maybe this is working as intended, but personally I think it would be better to decrease the floor to 27 days 23 hrs 59 mins 30 secs(if not explicitly considering whether the target date is February).
The text was updated successfully, but these errors were encountered:
Just spent a bit of time scratching my head about a unit test failure the other day, and assumed that it had something to do with leap-year. Instead, it looks like February is not considered "about a month":
The above happens because one month ago from a day in March will be 28/29 days, which is less than the cutoff for "about one month" which is:
Maybe this is working as intended, but personally I think it would be better to decrease the floor to
27 days 23 hrs 59 mins 30 secs
(if not explicitly considering whether the target date is February).The text was updated successfully, but these errors were encountered: