I'm trying to use timeago
(source), with datejs
, and it's not working. Here's some sample code I'd expect to work (given that timeago
and datejs
are loaded):
>>> d = new Date()
Mon Jun 21 2010 13:24:37 GMT-0400 (EST) { _orient=1, more...}
>>> d.toISOString() // datejs.toISOString
"2010-06-21T17:24:37.501Z" // this is a valid ISO8601 string, I believe
>>> $.timeago(d.toISOString()) // this should work
"NaN years ago"
I'd be much obliged for any input as to why this may be failing, and how one could go about fixing or circumventing this problem.
Thank you.
Brian
(I'm the author of Timeago)
The problem lies in the fact that the ISO8601 timestamp output by datejs includes a milliseconds value. Timeago currently doesn't support this detailed of an ISO8601 timestamp; it only supports a subset of the ISO8601 spec.
This isn't the first time I've heard about this problem; it's time there's a patch to handle the millis. I created an issue to track this. Look out for an upcoming version of Timeago. Likely v0.9.
Update: There's now a new version of Timeago (v0.9) that supports milliseconds in the timestamps. Download it here. Here's the relevant commit.