AndrewPoyntz / time-ago-pipe

An Angular pipe for converting a date string into a time ago
MIT License
130 stars 67 forks source link

Divide by zero exception results in odd message #8

Closed c-crosby closed 6 years ago

c-crosby commented 7 years ago

let seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000));

If those values are the same you get a message NAN years until it updates. We're able to generate this message because of some client side updates that remove any delay that would otherwise exist between fetching data on the server and displaying it.

iainbryden commented 7 years ago

+1

In my app I am replacing this: {{item.modified_at | date:'short'}}

with this:

{{item.modified_at | timeAgo}}

in about a hundred places.

If modified_at is NULL then 'NaN years ago' is displayed.

The date pipe handles this by not displaying anything and it would be great if this pipe could also just return an empty string.

AndrewPoyntz commented 6 years ago

From 1.3.2 It'll now return an empty string if the date is null or anything which can't be parsed as a date