matthewmueller / date

Date() for humans
http://matthewmueller.github.io/date/
1.48k stars 88 forks source link

same results for "ago" and "from now" #52

Open tj opened 10 years ago

tj commented 10 years ago
  console.log(date('50 minutes ago'));
  console.log(date('50 minutes from now'));

Tue Feb 04 2014 19:47:44 GMT-0800 (PST)
Tue Feb 04 2014 19:47:44 GMT-0800 (PST)

going to use this for a badass log query language :D

bulkan commented 10 years ago

Interesting in node v0.10.25 using the current master branch I get

>   console.log(date('50 minutes ago'));
Wed Feb 05 2014 15:13:08 GMT+1100 (EST)

>   console.log(date('50 minutes from now'));
Wed Feb 05 2014 16:53:09 GMT+1100 (EST)
tj commented 10 years ago

woah, weird, this was with 0.11.x, I'll try again tomorrow on 0.10.x

matthewmueller commented 10 years ago

@visionmedia sweet! let me know how it works out for you. it's definitely a bit rough around the edges (esp with month queries) but i'm planning on picking it back up again soon.

bulkan commented 10 years ago

Hey @MatthewMueller let me know if you need help :)

matthewmueller commented 10 years ago

seems to work okay for me. i tried 10.22 & 11.11:

console.log(date('50 minutes ago'))
console.log(date('50 minutes from now'))

Wed Feb 05 2014 11:52:51 GMT+0100 (CET)
Wed Feb 05 2014 13:32:55 GMT+0100 (CET)

@visionmedia also, one thing to keep in mind is that this parser prefers future dates (was made for scheduling). so if you type ambiguous phrases like '50 minutes', it'll assume '50 minutes from now'. that might not be ideal for logging. definitely down to explore ways to make it more general though.

matthewmueller commented 10 years ago

@bulkan awesome! the 3 big things are:

  1. getting english numbers working (in thirty minutes)
  2. getting months working (march 5th, january sixth, 12th of march)
  3. and #2
bulkan commented 10 years ago

1. sounds interesting. I shall work on it