News for hackers. Stuff that matters.
Re:Show HN: Durat.io by edraferi on Monday July 13, 2015 @11:03AM (#9878521)
You could bring this to a wider audience by integrating it with DuckDuckGo. You can arrange for DDG to send appropriate queries to your service with Spice [0].

If you don't want to handle the traffic, you can program an instant answer that runs on the DDG servers. Right now they have separate modules for time zone conversion [1], unit conversion [2] and uptime calculation [3]. Durat.io appears to hit a much wider set of use cases.

[0] https://duck.co/duckduckhack/spice_overview [1] https://duck.co/ia/view/timezone_converter [2] https://duck.co/ia/view/conversions [3] https://duck.co/ia/view/uptime

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @01:12PM (#9879444)
This is a great idea! Thanks!
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @05:51AM (#9877164)
Author here. I built this primarily to perform time-sheet calculations and to figure out what time it is in different cities easily when talking to friends overseas.

The site is the culmination of my experimentation with parsers, and specifically my last little Java TDOP parser library bychan (https://github.com/atorstling/bychan).

Please criticize / ask any questions and/or suggest anything below.

Re:Show HN: Durat.io by acqq on Monday July 13, 2015 @08:35AM (#9877714)
Looks OK.

Now looking at the examples, the answer for "now in zone Lisbon" gives

2015-07-13T13:31:47.968+01:00[Europe/Lisbon]

Why not just "today, 14:31:47, Lisbon"? If I enter the expression I don't actually like receiving the expression as the answer. Also, the whole "expression" of the translation of the question is displayed, when most probably the user doesn't need it every time, and then it's initially confusing.

Re:Show HN: Durat.io by virgoerns on Monday July 13, 2015 @09:17AM (#9877879)
https://xkcd.com/1179/

BTW: what does "today" mean when your wall clock shows e.g. 23:25:00? Is it "today in Lisbon" or "today at your timezone"?

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @12:25PM (#9879112)
Duratio actually kinda adresses this for time instants. If you enter "now" you get an instant. You can move it around the time axis and show its value at a specific zone by using "in zone PST" or similar. So if you enter "now PST" the timezone is considered redundant information and you get an error. But if you say "2013-01-10 PST" it parses. The conversion can be performed by entering "2013-01-10 pst in zone cet".

"today" and similar expressions are calculated in CET. I was considering customizing this or adding syntax for it, but it was de-scoped for the initial release.

Re:Show HN: Durat.io by acqq on Monday July 13, 2015 @09:25AM (#9877922)
I agree, it can be confusing too. At least as long as the "today" is the same on both places, it's clear. I'd keep the full date when it's not today on both places.

And do you prefer the current:

2015-07-13T13:31:47.968+01:00[Europe/Lisbon]

or something simpler?

Re:Show HN: Durat.io by frogpelt on Monday July 13, 2015 @09:59AM (#9878075)
Yet, the mouse over text for the comic says "ISO 8601 was published on 06/05/88 and most recently amended on 12/01/04."

Is this irony?

Probably not. Nothing is ever irony.

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @09:02AM (#9877814)
Thanks for your feedback. I agree that the representation is suboptimal. I will work on this if there is interest in the site. Regarding the ast representation, I will think about making it optional.
Re:Show HN: Durat.io by haberman on Monday July 13, 2015 @05:36AM (#9877125)
Reminds me a little of Date::Manip, the crazy Perl date library that would actually accept strings like:

"2 weeks ago on Friday at 13:45"

"Saturday Christmas 2010 at noon"

http://search.cpan.org/~sbeck/Date-Manip-6.50/lib/Date/Manip...

Re:Show HN: Durat.io by ejcx on Monday July 13, 2015 @10:42AM (#9878355)
Nice work. Looks like a useful tool, especially since time calculations can be confusing.

Remember to sanitize your input. http://durat.io/?q=%22/%3E%3Cscript%3Ealert(1);%3C/script%3E

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @10:46AM (#9878396)
Poor little Bobby Tables can't register :D Thanks
Re:Show HN: Durat.io by cbhl on Monday July 13, 2015 @05:15AM (#9877080)
Looks pretty good. Some nits:

The query "9999-99-99" throws java.time.format.DateTimeParseException (http://durat.io/?q=9999-99-99).

The query "2147483647 days + 1 day" throws java.lang.ArithmeticException (http://durat.io/?q=2147483647+days+%2B+1+day)

The query "1752-09-14 - 1752-09-02" returns PT288H, but arguably it should return PT24H (http://durat.io/?q=1752-09-14+-+1752-09-02, see also: https://en.wikipedia.org/wiki/Cal_(Unix)#Features)

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @05:26AM (#9877100)
Thanks for the QA! I haven't put all to much time into weeding out all the bugs yet. If the site gets popular that will definitely change.

edit: The first bug is a showstopper. Everything is supposed to be a bigint, so this will be fixed ASAP. The second one I will catch and print a nicer error for. The third one I will have to look into. I probably perform the calculation incorrectly by using the wrong temporal types. Thanks again.

Re:Show HN: Durat.io by JoshTriplett on Monday July 13, 2015 @05:37AM (#9877129)
The third one is the hardest to deal with:

  ~$ cal 9 1752
     September 1752     
  Su Mo Tu We Th Fr Sa  
         1  2 14 15 16  
  17 18 19 20 21 22 23  
  24 25 26 27 28 29 30  
This isn't the only bit of craziness you'd need to deal with if you wanted to handle historical times perfectly. For instance, consider attempting to get an accurate duration in hours of a time that extends across the daylight savings time switchover, historically, in a region where that has changed from year to year.

Another interesting one: 2015-07-01 - 2015-06-29 returns "PT48H", but it should be 48 hours and 1 second.

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @05:41AM (#9877137)
I'm currently passing on all the date calculations to the java.time API, so at least I won't have to do it all on my own. But it's sometimes a challenge to even pass it down the right way will all the different use-cases and temporal types available.
Re:Show HN: Durat.io by funerr on Monday July 13, 2015 @01:07PM (#9879400)
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @01:12PM (#9879437)
Yes, will be fixed.
Re:Show HN: Durat.io by kozhevnikov on Monday July 13, 2015 @04:28AM (#9876979)
Can it do anything wolframalpha.com can't?
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @04:42AM (#9877007)
Well, I'm not sure. I aimed at getting better than google calculator. But hopefully durat.io is quicker. Any requests are welcome!

edit: After doing some quick testing, Wolfram doesn't seem very good at time zone conversions or time span conversions.

Re:Show HN: Durat.io by DiabloD3 on Monday July 13, 2015 @04:37AM (#9876989)
I came here to say this. I use WA for all my time calculations.
Re:Show HN: Durat.io by sprain on Monday July 13, 2015 @06:03AM (#9877191)
My first try was "today + 6 weeks". Got "Lexing failed". My second try was "now + 2 hours in new york". Got "Lexing failed".

I suppose, I doesn't understand my accent ;)

Re:Show HN: Durat.io by przemoc on Monday July 13, 2015 @07:17AM (#9877384)
If you're *nix user, you can quite easily perform this kind of stuff using date, or at least using date from coreutils.

    $ date -d 'today + 6 weeks'
    Mon Aug 24 13:15:54 CEST 2015
    
    $ TZ=America/New_York date -d 'now + 2 hours'
    Mon Jul 13 09:16:17 EDT 2015
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @07:31AM (#9877439)
I had no idea. Great tip, thanks!
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @06:09AM (#9877196)
My NLP is not top notch :D. I figured that getting the parsing intuitive would be doable given the relatively narrow field, but I was proven wrong :) The result is that you need to learn the syntax a bit before it feels intuitive.

Regarding your specific examples: You need "in _zone_ new york" ATM. I think 'weeks' is missing simply as the result of an oversight :/ Thanks for the QA.

Re:Show HN: Durat.io by mtourne on Monday July 13, 2015 @02:41PM (#9880079)
I've been using Soulver on mac which does a lot of similar unit calculations, conversions etc. Works with time (but maybe not as advanced) and a lot of other things.
Re:Show HN: Durat.io by mapcars on Monday July 13, 2015 @04:47AM (#9877020)
Ever heard about rebol?

>> now

== 13-Jul-2015/11:46:45+3:00

>> now + 4:15

== 13-Jul-2015/16:01:52+3:00

Re:Show HN: Durat.io by anc84 on Monday July 13, 2015 @05:11AM (#9877073)
PostgreSQL also does time calculations spectacularly well.
Re:Show HN: Durat.io by mapcars on Monday July 13, 2015 @05:47AM (#9877149)
Yep, but my key point here is the syntax baked into the language itself.
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @04:49AM (#9877023)
nope, but thanks for the information. Please check out the time zone conversions as well.
Re:Show HN: Durat.io by ysr23 on Monday July 13, 2015 @08:38AM (#9877725)
oops, i borked it: http://durat.io/?q=0%2F0
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @09:00AM (#9877805)
Nicely done! At least you didn't try to paste half of wikipedia into the input field as my nice collegue did :)
Re:Show HN: Durat.io by ochronus on Monday July 13, 2015 @06:23AM (#9877236)
Haha, nice, good to see my old domain put to a better use :))
Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @07:33AM (#9877444)
What a coincidence! I spent a _lot_ of time trying to find some time-related domain name which wasn't taken. What were you using it for?
Re:Show HN: Durat.io by jastanton on Monday July 13, 2015 @12:22PM (#9879088)
Does PT stands for present time?

> 8:30am + 2.5 hours = PT11H

Re:Show HN: Durat.io by strictfp on Monday July 13, 2015 @02:39PM (#9880063)
Nope, it's https://en.wikipedia.org/wiki/ISO_8601 for 11 hours. Try "8:30 am today + 2.5 hours".
Re:Show HN: Durat.io by empressplay on Monday July 13, 2015 @04:20AM (#9876964)
Neat.
Re:Show HN: Durat.io by david927 on Monday July 13, 2015 @10:10AM (#9878143)
Great job! Well done.
Re:Show HN: Durat.io by magnusstubman on Monday July 13, 2015 @11:22AM (#9878664)