human-date icon indicating copy to clipboard operation
human-date copied to clipboard

Future date should use days

Open uriva opened this issue 8 years ago • 9 comments

If the date is something in 5 days, I would expect to get a day of the week result, e.g. "friday, 10am" instead of "in 5 days".

uriva avatar Feb 19 '17 10:02 uriva

In that case why not use the prettyPrint method instead of relativeTime?

hdate.prettyPrint(new Date(1416448704578), { showTime: true })
// November 19th, 2014 at 5:58 pm

I could see adding in a dayName method which would return the day of the week so you could format such a string easily. It would be very similar to the monthName.

montanaflynn avatar Feb 19 '17 23:02 montanaflynn

Cool.

As for the reason - because I do want it to say "tomorrow" when it is tomorrow and friday when friday is a couple of days away. Just as humans talk.

uriva avatar Feb 22 '17 08:02 uriva

There's times where it's appropriate to say "two months from now" rather than give a specific date so I don't think it should be a hard-coded rule in the library.

It should be easy to apply that logic outside of the library by checking how far out the date is and choosing the appropriate method or constructing your own string.

montanaflynn avatar Feb 23 '17 01:02 montanaflynn

why close? it's a valid feature request isn't it?

uriva avatar Feb 25 '17 04:02 uriva

The issue as it is currently is not something that I think makes sense for the library. I've suggested ways of how you could get the intended functionality and why I don't think it would make sense to change how the relativeTime method works.

The only thing that I would add would be a method for getting the date's human name such as "Friday" which isn't available with native date object similar to how human-date can return a month like "February". But that would be a separate issue I believe.

montanaflynn avatar Feb 25 '17 05:02 montanaflynn

I think in general both in relative and absolute time, day names are important. I think this library says "human-date" i.e. how humans talk. Humans don't say/understand "in 8 days", they say "Next Sunday".

Specifically I HAVE to use relativeTime, because I need to say stuff like "tomorrow" "in a couple of hours" "in 10 minutes" etc'. Right?

If we're not going to have that my only option is to write logic to see if it's this week, then just write the day name myself? Doesn't it sound cumbersome to you?

In what use case would a day-name in relativeTime be weird? Perhaps it should be a flag?

uriva avatar Feb 25 '17 11:02 uriva

perhaps other contributors care to comment as well? If I'm the only one thinking this makes sense then of course I must be wrong :) @nijikokun @reda-ea @gswalden

uriva avatar Feb 25 '17 11:02 uriva

I agree with @montanaflynn's comments on your original issue request.

That said, this line specifically I can agree with; However, that was not your original request:

Humans don't say/understand "in 8 days", they say "Next Sunday".

nijikokun avatar Feb 25 '17 21:02 nijikokun

As I understood the original request it was after a certain period of days to replace it with the date. If it's to change it to "Next Sunday" or "This Friday" then I think that would make sense but where is the cutoff, and does it extend to weeks, months, etc...? ("In six months" vs "In August").

@uriva I'll reopen this issue, could you make a list of dates in the future and what you expect the library to output? That would be very helpful to understand what you're seeking and for implementation as well.

montanaflynn avatar Feb 27 '17 18:02 montanaflynn