Jump to content

Duration Calculator — Add and subtract durations of time


Recommended Posts

This workflow extends Alfred's built-in calculator function. It recognizes durations as input and allows them to be added / subtracted. For example, if you type "8:00:18 - 4:19:23" into Alfred, you'll get "3:40:55".

 

You may add or subtract as many durations as you like (e.g. "3:32:55 - 5:57 + 4:50:14").

 

Download

 

Preview:

Image%202014-06-27%20at%205.14.54%20PM.j

Link to post

I'd love to see the source of this.  The workflow just has an executable.  Am curious as to how you extended the built-in calculator.

 

I'll probably post the source code on GitHub at some point. Here's a quick look in the meantime: http://cl.ly/code/3a402k0D1s2v

 

By the way, I'm not actually extending the codebase for Alfred's calculator. The workflow feels like an extension of the calculator because it is triggered by the same characters that trigger the normal calculator (i.e. 0-9 and +-). These keywords act as a bridge to the binary, which returns results very similar to Alfred's normal calculator. It's also very fast, mainly because it's written in C.

Link to post
  • 5 years later...
  • 2 months later...

For your latest code. I had to change from const char sep = ':'; to const char sep[2] = ":"; to get it to work. Compiled, ran, happy. Test for me was: "03:50+ 10:40" which di not result in 14:30, but in something with a 5 in the end - 13:45 I think it was. The first value did not get parsed to 3h 50min, but to 3h 5min. The latter worked!? 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...