Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat "dates" as dates rather than "midnight" #172

Open
philfreo opened this issue Mar 13, 2014 · 2 comments
Open

Treat "dates" as dates rather than "midnight" #172

philfreo opened this issue Mar 13, 2014 · 2 comments
Labels

Comments

@philfreo
Copy link

Right now datetimes:

<abbr class="timeago" title="2014-03-12T09:24:17Z">March 12, 2014</abbr>

and dates (without times):

<abbr class="timeago" title="2014-03-12">March 12, 2014</abbr>

are treated the same -- that is to say, dates (without times) are treated as exactly midnight (12:00:00) of that day, which leads to some undesirable cases when you really only care about date-level-precision for those dates.

For example, I want 2014-03-13 to say "today" and 2014-03-12 to say "yesterday". But what actually happens is 2014-03-12 says something like "14 hours ago".

My proposal is that if the T (time portion) of the date is present, the library works exactly as-is. However if the T (time) of the date is not present, it would work on date-only precision.

I would not want a global setting to change the precision, because I often want to mix between datetimes and dates on the same page.

@rmm5t
Copy link
Owner

rmm5t commented Mar 31, 2014

Interesting. Others have asked for "today" and "yesterday" precision, but I've always rejected the request, because the hour of the day was always in consideration and time zones affect "today" and "yesterday."

See #14

However, what you've proposed (cutting off the time to change the precision) could work well.

Please do investigate. Pull-request welcome.

@rmm5t rmm5t added the needs-pr label Dec 24, 2014
@tchalvak
Copy link

@philfreo This would actually be a great addition because:

  • Sometimes dates are being output without times.
  • Timeago works on such dates, but obviously with limited information.
  • If I this instant create a blog post that currently only reports it's date, using: <time class='timeago' datetime='2015-12-31'>2015-12-31</time> it's going to display as: 11 hours ago even the second after I make the post, even though a normal observer would understand that in normal parlance a date of 2015-12-31 can be applied vaguely to mean "sometime on this date" as opposed to exactly midnight.

I think this would be a great addition for the special case of non-time-attached dates within the last 24 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants