JA_UK Posted December 19, 2024 Posted December 19, 2024 Hi, I have a workflow which gets the current time (in format HHMM) to be stored as a variable. Alternatively, a time can be entered manually, to instead be stored as the variable. It then gets the current date (in format DDMMYY) to be stored as another variable. Alternatively, a date can be entered manually, to instead be stored as the variable. Both variables are later inserted into a URL which is opened in the browser. The website in question only accepts a time + date (in the URL I've created, using the variables) which: - Is rounded to a 15-min point in time (ie HH00, HH15, HH30 or HH45), which is no earlier than the current real time. For example: - If real time is 2115 hrs on 19th Dec 2024 the website would accept time '2115' and date '191224'. - If real time is 2116 hrs on 19th Dec 2024 the website would not accept this. It would only accept an earliest time of '2130', but would accept an earliest date of '191224'. - If real time is 2346 hrs on 19th Dec 2024 the website would not accept this. It would only accept an earliest time of '0000' and an earliest date of '201224'. My question: Is there a way to make the workflow 'round up' the time and date variables (whether current times / dates are used, or if they are entered manually), so they would be accepted by the website in line with the above 'rules'? I would like the workflow to be able to sort all of this automatically, if possible. Thank you.
vitor Posted December 19, 2024 Posted December 19, 2024 It would help if you shared a simplified version of the workflow. What you’re asking is doable but the exact method depends entirely on what you need exactly.
JA_UK Posted December 22, 2024 Author Posted December 22, 2024 Hi there. Link to a demo workflow as requested: https://www.dropbox.com/scl/fi/6264mvapuh9so8fsamn7p/Demo-Workflow.alfredworkflow?rlkey=9vf3gem1l0m2oug5ssl1g7l68&dl=0 Hope it makes sense... Thanks.
FireFingers21 Posted December 23, 2024 Posted December 23, 2024 @JA_UK I modified your demo workflow which should accomplish what you're looking for. I marked everything that I changed in orange and added descriptive notes. All you have to do is edit the openURL.sh External Script file to use your own URL. See the DuckDuckGo example I used as a placeholder.
JA_UK Posted December 23, 2024 Author Posted December 23, 2024 Thanks very much for your help! It works as it should. Another question if I may; is there a way to get the 'newTime' and 'newDate' variables out of the script, once the script has run, so they can be used elsewhere in the workflow? Thanks again.
JA_UK Posted December 23, 2024 Author Posted December 23, 2024 Update - without fully knowing what I'm doing I've managed to answer my own question (as per the above post). I have added this to the bottom of the script: print $newTime print $newDate I have then added a Split Arg function to the workflow immediately following the script, set up to save each value (split by new lines) as a variable which can be used later. Unsure if this is the 'proper' way to do this or not, but it seems to work. Thanks.
vitor Posted December 23, 2024 Posted December 23, 2024 That is a perfectly good way to do it! There are other methods, such as printing a specific JSON format that would immediately set those values as named variables, but your solution is simple and fine for the use case, you’re using the Split Arg Utility as intended.
JA_UK Posted December 23, 2024 Author Posted December 23, 2024 For me, JSON stuff is a bit advanced. I'd like to understand it, but I don't at the moment. I'll stick with Plan A. Thanks again.
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