What programming language is used in Automate blocks?

91 views
Skip to first unread message

Alex

unread,
Aug 1, 2023, 12:58:51 AM8/1/23
to Automate
I am trying to figure out how to convert a double to int and having no luck at all. I searched in the documents but there is no info on that. Can somebody explain what programming language is used in Automate and how to convert 5.000001  to 5 ?

Shari Shark

unread,
Aug 1, 2023, 1:02:46 AM8/1/23
to automa...@googlegroups.com
Why don't you just use the round function? 

On Tue, Aug 1, 2023, 12:58 Alex <istal...@gmail.com> wrote:
I am trying to figure out how to convert a double to int and having no luck at all. I searched in the documents but there is no info on that. Can somebody explain what programming language is used in Automate and how to convert 5.000001  to 5 ?

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/8e8967f4-d30d-4963-8c1e-762824f2746en%40googlegroups.com.

Henrik "The Developer" Lindqvist

unread,
Aug 1, 2023, 6:03:45 AM8/1/23
to Automate
Automate use its own programming language, similar to JavaScript but without the OOP. Anyhow, use the round function.

Alex

unread,
Aug 1, 2023, 9:18:36 AM8/1/23
to Automate
Thank you

Alex

unread,
Aug 1, 2023, 11:35:45 PM8/1/23
to Automate
I ended up with a situation where I need a "floor" rather than "round".  Or please let me know how to replace parseInt function without floor.
Basically calculate a call duration catching start date and end date with "Now". Here is what I would do in poor javascript

// Calculate difference in milliseconds
let differenceInMs = endTime - startTime;

// Convert difference to minutes and seconds
let differenceInMinutes = differenceInMs / 1000 / 60;
let minutes = parseInt(differenceInMinutes);
let seconds = Math.round((differenceInMinutes - minutes) * 60);

Alex

unread,
Aug 1, 2023, 11:37:49 PM8/1/23
to Automate
Or this but again I need ParseInt or Floor:

// calculate difference in milliseconds
let differenceInMs = endTime - startTime;

// convert difference to minutes and seconds
let differenceInSeconds = Math.floor(differenceInMs / 1000); 
let minutes = Math.floor(differenceInSeconds / 60);  
let seconds = differenceInSeconds % 60;

Shari Shark

unread,
Aug 1, 2023, 11:41:38 PM8/1/23
to automa...@googlegroups.com
What exactly are you trying to achieve? Is it up convert duration into hh, mm and ss? 

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.

Alex

unread,
Aug 1, 2023, 11:43:04 PM8/1/23
to Automate
I want to calculate the duration of a phone call.  I have start date and end date, now I need to calculate minutes and seconds

Shari Shark

unread,
Aug 1, 2023, 11:45:21 PM8/1/23
to automa...@googlegroups.com
There's a few functions readily available.

durationFormat
dateFormat
trunc
floor

You should read the documentation.

Alex

unread,
Aug 2, 2023, 12:21:00 AM8/2/23
to Automate
durationFormat  was exactly what I needed. You the man!
Reply all
Reply to author
Forward
0 new messages