Time duration as ##:##:## in a phone call flow
Moderator: Martin
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Time duration as ##:##:## in a phone call flow
Hi, I'm trying to get a report written when a phone call has ended. But I would like to get the time duration in the format HH:mms:ss. Is there an easy way to do this?
In the flow below it is just the three last actions that are relevant to this problem. Variable vlangd, does the trick, but the format is "1m 10s". That format is not easily used in excel for totals and so on. In formatted variable vlangd2 , the format is right , but for some reason it adds one hour to the time. As you can see I have done a work around. Firstly I have added call_duration * 1000 to call_time to get an end time (variable vsluttid ) and that value shows correctly (with formatting applied). But when I reduce call_time with vsluttid (variable vlangd2) and time format it , the value shows up as 01:01:10 when in real life it is just 1 minute and 10 seconds.
Anyone out there who can help me?
In the flow below it is just the three last actions that are relevant to this problem. Variable vlangd, does the trick, but the format is "1m 10s". That format is not easily used in excel for totals and so on. In formatted variable vlangd2 , the format is right , but for some reason it adds one hour to the time. As you can see I have done a work around. Firstly I have added call_duration * 1000 to call_time to get an end time (variable vsluttid ) and that value shows correctly (with formatting applied). But when I reduce call_time with vsluttid (variable vlangd2) and time format it , the value shows up as 01:01:10 when in real life it is just 1 minute and 10 seconds.
Anyone out there who can help me?
Last edited by angelatwork on 19 Feb 2014 11:31, edited 1 time in total.
Best regards,
AngelAtwOrk
AngelAtwOrk
Re: Time duration as ##:##:## in a phone call flow
That's because your time zone is different from GMT; I have the same problem.
Try this: {triggertime, dateformat, timezone, UTC, HH:mm:ss}
Try this: {triggertime, dateformat, timezone, UTC, HH:mm:ss}
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Re: Time duration as ##:##:## in a phone call flow
Thanks for the reply
, it does the trick, BUT what is it actually doing, what is the logic behind?
Am I not just forcing a faulty script to reduce one hour from my calculation by formatting my vlangd2 in (the wrong) time zone UTC or is the scripting actually right?
See response/question in the post below (written later) please

Am I not just forcing a faulty script to reduce one hour from my calculation by formatting my vlangd2 in (the wrong) time zone UTC or is the scripting actually right?
See response/question in the post below (written later) please
Last edited by angelatwork on 19 Feb 2014 13:30, edited 2 times in total.
Best regards,
AngelAtwOrk
AngelAtwOrk
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Re: Time duration as ##:##:## in a phone call flow
Deleting my earlier response;
Never mind my own different variables,let us use triggertime in the example. It works and makes my text less confusing, hopefully
Thanks for the reply
, it does the trick, BUT what is it actually doing, what is the logic behind?
Am I not just forcing a faulty script to reduce one hour from my calculation of elapsed time (calculated in let's name it V1), by formatting the variable/expression V1 to (the wrong) time zone UTC or is the scripting actually right?
When the flow is run the text file shows as follows;
{triggertime,dateformat,HH:mm:ss} triggered at the end of the call, shows 15:59:28 in written to file {call_time,dateformat,HH:mm:ss} shows 15:58:18 written to file
So why does variable V1, triggertime - call_time (substracted) {V1,dateformat,HH:mm:ss}, show 01:01:10 (one extra hour too many) written to file instead of the correct elapsed time 15:59:28 - 15:58:18 = 00:01:10, when the variables call_time and triggertime show up correctly in the same format?
Triggertime with time zone format UTC by itself shows, as expected, one hour earlier than my time zone time ,since my time zone is Sweden.
Is it really correct scripting to add the wrong time zone to the variable V1 with the calculation of elapsed time, even though it does substract the extra hour from the calculation?
Please I am really interested in an explanation to this, to understand better
Never mind my own different variables,let us use triggertime in the example. It works and makes my text less confusing, hopefully

Thanks for the reply

Am I not just forcing a faulty script to reduce one hour from my calculation of elapsed time (calculated in let's name it V1), by formatting the variable/expression V1 to (the wrong) time zone UTC or is the scripting actually right?
When the flow is run the text file shows as follows;
{triggertime,dateformat,HH:mm:ss} triggered at the end of the call, shows 15:59:28 in written to file {call_time,dateformat,HH:mm:ss} shows 15:58:18 written to file
So why does variable V1, triggertime - call_time (substracted) {V1,dateformat,HH:mm:ss}, show 01:01:10 (one extra hour too many) written to file instead of the correct elapsed time 15:59:28 - 15:58:18 = 00:01:10, when the variables call_time and triggertime show up correctly in the same format?
Triggertime with time zone format UTC by itself shows, as expected, one hour earlier than my time zone time ,since my time zone is Sweden.
Is it really correct scripting to add the wrong time zone to the variable V1 with the calculation of elapsed time, even though it does substract the extra hour from the calculation?
Please I am really interested in an explanation to this, to understand better
Best regards,
AngelAtwOrk
AngelAtwOrk
Re: Time duration as ##:##:## in a phone call flow
Automagic internally uses the number of milliseconds since 1.1.1970 00:00:00 (UTC) to store a date.
To see the real numeric value of a date, you can create a new flow, add a condition Debug Dialog and manually execute the flow. This will show a dialog that lists all currently available variables. triggertime should be displayed with a value like 1392923563308 (milliseconds since 1970 UTC) and a more human readable value like 2014-02-20 20:12:43.308. The latter also considers the timezone of your device to format the date so the number 1392923563308 would not appear as the same human readable date on devices in different timezones.
When you explicitly use UTC to format a difference like 70000ms, the time in UTC (1 minute 10 seconds after midnight) happens to be the same as the duration so this should be fine to do as long as your duration is less than 24 hours.
To see the real numeric value of a date, you can create a new flow, add a condition Debug Dialog and manually execute the flow. This will show a dialog that lists all currently available variables. triggertime should be displayed with a value like 1392923563308 (milliseconds since 1970 UTC) and a more human readable value like 2014-02-20 20:12:43.308. The latter also considers the timezone of your device to format the date so the number 1392923563308 would not appear as the same human readable date on devices in different timezones.
When you explicitly use UTC to format a difference like 70000ms, the time in UTC (1 minute 10 seconds after midnight) happens to be the same as the duration so this should be fine to do as long as your duration is less than 24 hours.
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Re: Time duration as ##:##:## in a phone call flow
Thanks for your thorough explanation
. If I understand you correctly, it boils down to the following ;
Even though Both triggertime and call_time are in milli seconds from 1970 UTC, After calculating the variable v1 =triggertime - call_time, when writing to file, the Android steps in and says "hey there, I better add an extra hour to the result, since you live in Sweden". The hour is added by the dateformat, localizating by default when not specified, since it thinks it's a time of day, not a time duration.
To do it properly can I write variable v1= ( triggertime, dateformat, HH:mm :ss) - (call_time, dateformat, HH:mm :ss), or how should I handle it, if I don't want to use UTC in writing to file?
Thanks again

Even though Both triggertime and call_time are in milli seconds from 1970 UTC, After calculating the variable v1 =triggertime - call_time, when writing to file, the Android steps in and says "hey there, I better add an extra hour to the result, since you live in Sweden". The hour is added by the dateformat, localizating by default when not specified, since it thinks it's a time of day, not a time duration.
To do it properly can I write variable v1= ( triggertime, dateformat, HH:mm :ss) - (call_time, dateformat, HH:mm :ss), or how should I handle it, if I don't want to use UTC in writing to file?
Thanks again
Best regards,
AngelAtwOrk
AngelAtwOrk
Re: Time duration as ##:##:## in a phone call flow
Yes, correct.
You can use this method to write the value to a file: action Write to File: {triggertime-call_time,dateformat,timezone,UTC,HH:mm:ss}
You could also calculate the difference in an action Script: diff=triggertime-call_time; and then write it to a file with Write to File: {diff,dateformat,timezone,UTC,HH:mm:ss}.
Regards,
Martin
You can use this method to write the value to a file: action Write to File: {triggertime-call_time,dateformat,timezone,UTC,HH:mm:ss}
You could also calculate the difference in an action Script: diff=triggertime-call_time; and then write it to a file with Write to File: {diff,dateformat,timezone,UTC,HH:mm:ss}.
Regards,
Martin
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Re: Time duration as ##:##:## in a phone call flow
Well, that is what I have been doing really after the suggestion above. I was just afraid that I will see the writing to file later and find it to be illogical with UTC and wonder why. But hopefully it will stick in my mind after your explanation. I have to accept, that there is no easy solution for scripting the format into the variable
Thanks again

Thanks again
Best regards,
AngelAtwOrk
AngelAtwOrk
-
- Posts: 186
- Joined: 12 Feb 2014 01:45
Re: Time duration as ##:##:## in a phone call flow
Saw that I lost half of my question. The other hall was since you already have the variable call_duration in seconds . Is it possible to make it into the number format HH:mm:ss without coding for "if more than 60 seconds then..." etc ? Not just the string 1m 10s.
Best regards,
AngelAtwOrk
AngelAtwOrk
Re: Time duration as ##:##:## in a phone call flow
You can use the same mechanism as before but multiply by 1000 to convert the call_duration to milliseconds first:
-action Notification on Screen: {call_duration*1000,dateformat,timezone,UTC,HH:mm:ss}
-action Notification on Screen: {call_duration*1000,dateformat,timezone,UTC,HH:mm:ss}