MatthewYork / DateTools

Dates and times made easy in iOS
MIT License
7.22k stars 952 forks source link

Any plan to support "Time Later" beside "Time Ago"? #26

Open qinidea opened 10 years ago

qinidea commented 10 years ago

I'm developing a Timer app and I need display something like "It will run in 5 minutes". In android I can use DateUtils.getRelativeTimeSpanString and it works fine. But in iOS I cannot find any solution. Actually I can write my own codes, but the most difficulty is localization. "Time Ago" is perfect for many(maybe most) projects, but it's not enough for me... Btw I can contribute Chinese localization.

MatthewYork commented 10 years ago

We recently had a need for this in one of our projects as well! My only concern is with phrasing.

Would the equivalent of "5 minutes until" work well in Chinese?

qinidea commented 10 years ago

So glad to hear you need it too! Yes it works pretty well in Chinese!

martinjuhasz commented 10 years ago

i also have the need for something like "in x minutes". using timeAgo doesn't work (obviously).

(lldb) po arrivalTime
2014-10-29 11:48:00 +0000

(lldb) po [NSDate date]
2014-10-29 11:46:48 +0000

(lldb) po arrivalTime.timeAgoSinceNow
A minute ago
MatthewYork commented 10 years ago

There is a set of methods that you can build logic around, if internationalization is not required. These are the "timeUntil" methods that return numbers.

Unfortunately, entirely new translations would be required to create "in x minutes". Would you like me to work on a structure for it? Of course there will be very few translations in the beginning.

martinjuhasz commented 10 years ago

i'm going to create it myself, no problem here. since the translations are very specific, i think its a better practise to just use the "timeUntil" methods

yepher commented 9 years ago

Hi I am the maintainer of GitHub CoreDataUtility and OSX LogRabbit for Android. I am adding "TimeAgo" as possible rendered date format. While testing I found that only dates from the past and present are supported. Due to the nature of CoreDataUtilty I need to handle all ranges of dates (future, present and past).

First question is has someone already added support for this and I am missing it?

If not would it be OK if I add this to "TimeAgo". The name is not perfect but I don't think there should be separate method based on the tense of the date. Or I could make a new method that is "FuzzyDate" that includes "TimeAgo" and "TimeUntil" functionality.

My biggest concern, if I implement this, is the localization. It's not that important for my utility but is very important for this library.

joelk commented 8 years ago

+1, I'd really like to see this.

liakhandrii commented 8 years ago

It would be great to have such a method

oleynikd commented 8 years ago

+1

sebyddd commented 8 years ago

👍

futuretap commented 7 years ago

+1

alejandrorosas commented 6 years ago

+1

antonio83franco commented 6 years ago

+1