deanishe Posted July 4, 2017 Share Posted July 4, 2017 On 03/09/2016 at 0:55 PM, MuppetGate said: if I was excluding weekends and which pushed out the date to another weekend, then I wasn't accounting for the new weekend and pushing the date out even further. From my reading of your code, I think the issue is that you jump straight to the end date, figure out which days should have been excluded, and then adjust the end date accordingly (which you then need to repeat ad infinitum on the new range). Rather, I think the right way to handle excludes would be to increment/decrement the date one day at a time, ignore that date if it's excluded, and keep going until your count matches the requested delta: delta = 10 # wanted difference in days exclude = 'weekends' count = 0 # current difference in days current = start_date while True: if is_excluded(current, exclude): # some magic goes here continue if count == delta: # got result break # increment counter and current date for next loop current += timedelta(days=1) count += 1 print(current) # the requested end date Link to comment
bivalvegruff Posted October 15, 2018 Share Posted October 15, 2018 Excellent workflow, many thanks!! I have a couple of suggestions: Date format yymmdd. Output format in number of days, not months, years, or weeks, without words – to make it easy to work with in eg Numbers. Calculating accumulated time, like 20180102-20180107 + 20180327-20180328. :) Link to comment
Guy Stan Posted October 19, 2018 Share Posted October 19, 2018 Thank you very much for creating such a great workflow. I have found a few things that do not work and how to fix them. The contents of /usr/bin/osascript currently refer to Alfred 2, not Alfred 3: to get the workflow to work with Alfred 3, all instances of: tell application "Alfred 2", need to be replaced with: tell application "Alfred 3" The first /usr/bin/osascript (the one linked to dcalc) has all escapings active. Removing all escapings should allow the workflow to work properly without throwing an error when the output is anything else than just a date. For example if the output of the workflow is "DATE at TIME" or anything else resulting for a calculation that is more than just a date (m MONTHS, w WEEKS, d DAYS, h HOURS) an error will be thrown currently. dcalcset date and time: currently the call to this command doesn't work. The reason is that on line 26 of the file date_time_format_list.py the call to date_time = datetime.datetime.now() should be replaced with date_time = datetime.now() I recommend activating "Automatically paste to frontmost app" in the "Copy to Clipboard" module that is connected to dcalc Link to comment
MuppetGate Posted October 22, 2018 Author Share Posted October 22, 2018 (edited) Okay, I’ve scored a bit of time to revisit the date app and fix a few bugs. Not everything has been looked at because I’ve got to head off again for a while, but what I have done is: – Upgraded the workflow library – Fixed a few of the scripts that referred to Alfred 2 instead of Alfred 3 (I guess this means Alfred 2 is no longer supported). – A bit of a general code tidy up The big piece of work though, is the restoration of the exclude functionality, which should work properly, but with limitations. To prevent it blowing things up if the search combination doesn’t produce a valid match, I’ve limited the workflow to about 300 attempts to look for a match. After that, I’ll throw an error. So how does it work? Here’s a quick example. Say you’re a busy project bod and you have a piece of work that’s going to take three weeks. So you enter the data expression: dcalc today + 3w And that gives you a date three weeks into the future. But hang on a sec: no one works weekends, so how long will it take if there are no weekends included: dcalc today + 3w exclude weekends So now the date will be further into the future because weekends are not counted as part of the project. (Another way to look at it is if people worked weekends then the project could be brought in at an earlier date). You can exclude individual days: dcalc today + 3w x weekends 28.10.2018 This will exclude all weekends and also the 28th of October. Note that you can just use x or ex instead of exclude. We can exclude other days: dcalc today + 3w x Tuesdays Wednesdays Fridays We can also do ranges: dcalc today + 3w exclude Tuesdays 30.10.2018 to 05.11.2018 02.12.2018 This beast will exclude Tuesdays, all days between the 30.10.2018 and 05.11.2018, and it will also exclude 02.12.2018 We can also do: dcalc today + 3w exclude all except tuesdays Error checking is minimal, but this kind of stuff won’t work: dcalc today + 3w ex all except wednesdays wednesdays dcalc today + 3w x weekends weekdays Because every day has been excluded. The update can be found in the usual place: http://www.packal.org/workflow/date-calculator The usual disclaimers apply, so don't use this to schedule brain surgery. Use a calendar. Edited October 22, 2018 by MuppetGate cands 1 Link to comment
MuppetGate Posted October 22, 2018 Author Share Posted October 22, 2018 Is there a replacement for Packal yet? I haven't been keeping up. Link to comment
Guy Stan Posted October 24, 2018 Share Posted October 24, 2018 (edited) It seems that the examples that you have given above only work if you write without capitals: dcalc today + 3w x tuesdays wednesdays fridays Edited October 24, 2018 by Guy Stan Link to comment
xilopaint Posted October 24, 2018 Share Posted October 24, 2018 On 10/22/2018 at 4:39 AM, MuppetGate said: Is there a replacement for Packal yet? I haven't been keeping up. You can use the Alfred-Workflow library already embedded to Date Calculator for adding self-updating capabilities to your workflow. Here's how: https://www.deanishe.net/alfred-workflow/api/index.html#id12 Link to comment
famaus Posted April 19, 2022 Share Posted April 19, 2022 I am using Alfred 4.6.4 with Python 2.7.18. Lately, for this Workflow, when I start typing any argument I get web search option and the arguments are not passed to Workflow. I am not sure if the Workflow is broken after the update or if its my system. Can you please help? Link to comment
face Posted June 24, 2022 Share Posted June 24, 2022 macOS Monteray 12.4 Date Calculator stop to works: any help please ? In debugging mode i receive this error message: [07:03:27.356] Date Calculator[Script Filter] Queuing argument '19.12.2022 - 20d' [07:03:27.369] Date Calculator[Script Filter] Script with argv '(null)' finished [07:03:27.369] ERROR: Date Calculator[Script Filter] Code 127: /bin/bash: python: command not found Link to comment
Vero Posted June 24, 2022 Share Posted June 24, 2022 @face This is due to macOS removing Python 2 from Monterey 12.3. You can read more about it here: https://www.alfredapp.com/blog/guides-and-tutorials/python-2-workflows-on-macos-monterey-12-3/ Once you've reinstalled Python 2, grab the updated version of this workflow here: https://github.com/alfredapp/updated-third-party-python2-workflows#readme Cheers, Vero GatorMapi 1 Link to comment
giovanni Posted June 24, 2022 Share Posted June 24, 2022 very nice! I migrated it to Python 3 @face @famaus give it a try if you like! HeatherH, vitor and wunderkidchaos 1 2 Link to comment
face Posted June 24, 2022 Share Posted June 24, 2022 @giovanni thanks a lot !!! It works now like a charm. Btw: any chance to add a way to insert dmyyyy as set date ? Link to comment
giovanni Posted June 24, 2022 Share Posted June 24, 2022 32 minutes ago, face said: dmyyyy as set date like long UK (24-06-2022) but no hyphens (24062022)? Link to comment
face Posted June 24, 2022 Share Posted June 24, 2022 no i use (italian date format) today 24th june 2022 i'd like to insert 24.6.2022 (now seem only possible to insert 24.06.2022 with 0 added) and on 1st july 2022 i'd like to insert 1.7.2022 (now seem only possible to insert 01.07.2022 with 0 added) is it possible to setup that format date ? Link to comment
giovanni Posted June 24, 2022 Share Posted June 24, 2022 17 minutes ago, face said: is it possible to setup that format date ? try this Link to comment
vitor Posted June 24, 2022 Share Posted June 24, 2022 3 hours ago, giovanni said: I migrated it to Python 3 Added as an alternative on the table. Link to comment
face Posted June 24, 2022 Share Posted June 24, 2022 It not works. I receive this error message: Link to comment
giovanni Posted June 24, 2022 Share Posted June 24, 2022 (edited) oh I see, I didn't test the calculations... this format needs a bit of a workaround, could you try this version? @face Edited June 24, 2022 by giovanni Link to comment
face Posted June 24, 2022 Share Posted June 24, 2022 @Giovanni thank you so much, it works now like a charm !!! THANKS !!! Link to comment
GatorMapi Posted July 16, 2022 Share Posted July 16, 2022 On 6/24/2022 at 3:04 PM, giovanni said: oh I see, I didn't test the calculations... this format needs a bit of a workaround, could you try this version? @face That link has been removed. Is there any way to change how the date is displayed in Alfred? I see at least 3 different places to change the format in the workflow. Instead of: dd.mm.yy how do I change it to? mm.dd.yy I tried to edit the workflow but the output is the same. What do you think? Link to comment
giovanni Posted July 16, 2022 Share Posted July 16, 2022 hi @GatorMapi this is the most recent release. enter dcalcset to set the date format cands 1 Link to comment
GatorMapi Posted July 18, 2022 Share Posted July 18, 2022 @giovanni when I go to type `dcalc now` or `dcalc tomorrow` for example it takes me to my default search list. When this happens I usually fix it by selecting "require an argument" in the dropdown list but its already selected. Before the update the workflow seemed to work fine. Any ideas what I could be doing wrong? Link to comment
vitor Posted July 18, 2022 Share Posted July 18, 2022 (edited) 4 hours ago, GatorMapi said: Any ideas what I could be doing wrong? Open the debugger, set the log output to “All Information”, and perform the failing action. That should give hints to what is happening. Edited July 18, 2022 by vitor Link to comment
HeatherH Posted July 18, 2022 Share Posted July 18, 2022 On 6/24/2022 at 7:13 AM, giovanni said: very nice! I migrated it to Python 3 @giovanni Thank you for updated Dcalc. It is one of my most-used workflows. Eternal gratitude. giovanni 1 Link to comment
face Posted July 18, 2022 Share Posted July 18, 2022 2 hours ago, HeatherH said: @giovanni Thank you for updated Dcalc. It is one of my most-used workflows. Eternal gratitude. +1 🤩 giovanni 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now