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

Support future dates as "from now" #67

Closed
clairernovotny opened this issue Jan 24, 2014 · 10 comments
Closed

Support future dates as "from now" #67

clairernovotny opened this issue Jan 24, 2014 · 10 comments

Comments

@clairernovotny
Copy link
Member

Looks like dates are all in the past.

How about future dates - should use the same breakdowns but be "from now" instead.

Also, maybe +/- some threshold, there could be a "now"

@MehdiK MehdiK mentioned this issue Jan 24, 2014
@MehdiK
Copy link
Member

MehdiK commented Jan 24, 2014

That's something I've been meaning to add for a while. Hopefully will get around to do it soon. I do accept and appreciate Pull Requests too :)

@clairernovotny
Copy link
Member Author

I can do the English part, but how do you deal with the localization? I have no idea how to translate "from now" :)

@MehdiK
Copy link
Member

MehdiK commented Jan 24, 2014

You do the English part using resources like I've done for the past dates. I will take care of translations and buy you a beer if I meet you :)

@clairernovotny
Copy link
Member Author

k, lemme see what I can do. I have a three hour flight tomorrow, so I'll fork, check into a branch and send you a PR when I can.

@clairernovotny
Copy link
Member Author

So looking at the code, to promote code/string reuse, I would split the x days ago into three resources -- "x days", then "ago" and "from now".

As to not break the other language translations, I'll create new resources for all, DateHumanize_SingleDay, DateHumanize_MultipleDays, etc. and then DateHumanize_Past and DateHumanize_Future (and perhaps a DateHumanize_Now).

I'll have my code use those new ones and then the other language resources can be adapted. Does that make sense?

@MehdiK
Copy link
Member

MehdiK commented Jan 24, 2014

I am a bit confused to be honest. Could you explain a bit more please?

I haven't thought about this much; but I was thinking we could rename the existing resources to include a _Past and then create new _Future ones (e.g. DateHumanize_Past_SingleDay and DateHumanize_Future_SingleDay). I have once renamed the resource names and it's a simple find and replace.

@clairernovotny
Copy link
Member Author

That could work, but I was going for reducing duplication of the single/multi combos multiplied by past/future. I was gonna just have a _SingleDay string, and then a _Past and a _Future.

So the string format would look like this pseudo-code:

var isFuture = date > DateTime.UtcNow;

if(...) //single day
{
   return string.Format("{0} {1}", formatter.GetSingleDay, isFuture ? formatter.Future : formatter.Past);
}

@MehdiK
Copy link
Member

MehdiK commented Jan 24, 2014

Ahhhh, gotcha. Thanks for explaining. That will work for English but it's going to make it rather difficult for localization. Redundancy in resources turned out to be the simplest solution to the localisation requirements of the library; so I'd say lets just add in new resources. I just realized that we don't actually need to rename the old resources (like I said above) for the dates in the past as resources already have an Ago postfix. So we just have to add DateHumanize_ resources ending with FromNow for future dates.

Thoughts?

@clairernovotny
Copy link
Member Author

Okay, works for me. No need to deal with language craziness :)

@MehdiK
Copy link
Member

MehdiK commented Jan 31, 2014

Implemented in #68

@MehdiK MehdiK closed this as completed Jan 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants