New Duration Calculator Goodie #3143
Comments
@GuiltyDolphin We discussed this on slack. |
@sam09 Hey Sam, thanks for this! First things first, make sure you are familiar with the source https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/DateMath.pm - perhaps have a little play with it. Okay, here's a some info that may be useful: PackagesI really like DateTime::Duration and DateTime::Format::Human::Duration (you may not need the second one) for working with date units. TriggeringYou shouldn't need to worry - we already have triggers for the common units: second, minute, hour etc. (I don't think it supports You may need to add another regex or two to match I'm working on refactoring the tests at the moment - hopefully it won't create too many issues! @sam09 If you have any ideas, suggestions or questions don't hesitate to let me know! When you've got the basics working just ping me in a PR and I'll come and have a look. |
Hi.. I tried the to trigger the regex. However I am unable to figure out the trigger for queries like '2 hours + 1 hour 20 min' |
@sam09 You'd just want another regex for forms using the existing units; basically you'd want to combine |
@GuiltyDolphin As you said the regex would be But the issue would be to extract the quantities and corresponding units from both ends and then perform the Or write regex in the complete form and then extract the matching groups using the old-fashioned way ( I am hoping there is a better way to do this. Any ideas? |
@sam09 The existing method should be fine - just use named captures, e.g., |
Can I suggest that this be renamed to Duration Calculator? It's a slightly pedantic point, but time can mean either an "amount" of time or a "point in time"; whereas duration exclusively means the "amount of time". To me "time calculator" could be adding datetimes together |
@mintsoft I agree that "time calculator" is a little vague. I think "Duration Calculator" makes sense with the package names. "Time" could mean 8:45pm + 2.5 hours or something similar. |
Ahk, bummer - @sam09 I forgot about #2897 - that'll make this pretty incompatible with DateMath (unless we have a very dynamic front end). It may be worth implementing this as a separate Goodie after all - though I reckon you could use a decent portion of the DateMath codebase for triggering/handling units (and ofc I'll still advise :) ). |
@sam09 Here, this should be a decent page for this Goodie https://duck.co/ia/view/duration_calculator @tagawa Could you set @sam09 as the maintainer on that please? |
@GuiltyDolphin I set @sam09 as the maintainer for you 👍 |
@edgesince84 thanks a lot.... |
@sam09 Basically everything I've said should still apply - you'll want to use the suggested packages and possibly build upon those regexes in DateMath - the main difference being that you'll be working in separate files; you still happy to do this? |
@GuiltyDolphin sure... Except that I am going to trouble you with even more questions now |
@sam09 don't be afraid to hit us up in Slack if you have any questions! |
#3205 Fixes the issue |
A simple calculator that enables users to enter queries of time like 3 hours 45 minutes + 1 hour 20 minutes and returns the calculated result.
IA Page: https://duck.co/ia/view/duration_calculator
The text was updated successfully, but these errors were encountered: