Jump to content

Round up entered date & time to the next 15-mins


Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

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...