matthewmueller/date

Making a guess at "tomorrow at 11"

mattmcdonald-uk opened this issue · 5 comments

When you enter at a time without specifying AM or PM or something to frame that time (e.g. morning), it ignores the time value.

tomorrow morning at 11
tomorrow at 11am
tomorrow at 11:00
tomorrow at 11

Of those 4 examples, the first 3 give the same result, the last one ignores the time.

I would have thought presuming someone is using a 24 hour clock format is the best way to handle this, so tomorrow at 11 always defaults to 11am?

But why not write 23? I think it's the most logical way.

Sure, for 11PM that would make sense. But putting "tomorrow at 11" will not become tomorrow at 11AM

Maybe stop the user from entering it and ask that the user to correct it? But it's more bytes of data...

It should probably give you the next available time if no context is given.

Added a test like below and it passes.

it('tomorrow at 11', function () {
  var after = new Date('May 13, 2013 13:30:00');
  var date = parse('tomorrow at 11', after);
  assert('11:00:00' == t(date));
  assert('5/14/13' == d(date));
});