Time duration as ##:##:## in a phone call flow

Post your questions and help other users.

Moderator: Martin

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

Re: Time duration as ##:##:## in a phone call flow

Post by angelatwork » 22 Feb 2014 18:04

Thanks
Best regards,
AngelAtwOrk

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Time duration as ##:##:## in a phone call flow

Post by MURTUMA » 24 Feb 2014 14:43

Martin, thanks for your answer on that other thread. I've been eyeing this thread but couldn't see anything suitable for me. I tried different things through trial and error and still couldn't find solution.

Currently this is where I'm at. Could you help me forward? http://automagic4android.com/flow.php?i ... a5adaef6ee

The "duration" variable received from Poweramp is in seconds. The notification output returns always 02:00:00 and the script(before formatting in notification action) returns always some integer even though there should be some digits also.

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

Re: Time duration as ##:##:## in a phone call flow

Post by angelatwork » 24 Feb 2014 16:54

A thought;
Probably the number of seconds you get from PowerAmp is nothing more than number (it does not represent a point in time or a time duration).
In Excel you have an adapted format not the normal time/date format to calculate hours and minutes and so on, I could not find any number formats here that would do the trick.

But I would think you should be able to make it look right HH:mm:ss, by nested "if expressions" or similar, although it will not be a time format really. I am not able to write an expression in "Automagic code" to make it into HH:mm:ss, as I could in Excel/VB.

Hope Martin can help you out ( I am very interested, calculating/formatting time is always troublesome)
Best regards,
AngelAtwOrk

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Time duration as ##:##:## in a phone call flow

Post by MURTUMA » 24 Feb 2014 17:21

The number is a variable that shows a length of the song so yes, it is just a plain number. I should somehow make Automagic to understand that were talking about seconds(or milliseconds, whatever suits Automagic) so it could be formatted.

As I stated in my original thread, I was able to format it to "XXm YYs" , but that format is problematic because of the extra space between minutes and seconds. Toast message sometimes cuts the seconds to a new line which makes it hard to read fast and in many other ways that is impractical way to show song duration.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Time duration as ##:##:## in a phone call flow

Post by Martin » 24 Feb 2014 17:21

The duration of the song is returned in seconds by PowerAMP so you can use following action to display the duration formatted:
Notification on Screen: {duration*1000,dateformat,timezone,UTC,HH:mm:ss}
This should display something like 00:02:54 when the song has a duration of 174 seconds.

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

Re: Time duration as ##:##:## in a phone call flow

Post by angelatwork » 24 Feb 2014 17:35

ok, thanks Martin,
it clarifies it for me, at least (it was in seconds then). Hope it works for you Murtuma :)
Best regards,
AngelAtwOrk

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Time duration as ##:##:## in a phone call flow

Post by MURTUMA » 24 Feb 2014 17:57

That works. However is there a way to remove the hours if it shows zeroes?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Time duration as ##:##:## in a phone call flow

Post by Martin » 24 Feb 2014 19:03

If the songs are not that long you could remove the hours completely (Notification on Screen: {duration*1000,dateformat,timezone,UTC,mm:ss}) or use a condition and two actions:
-condition Expression: duration>60*60
-->true: -action Notification on Screen: {duration*1000,dateformat,timezone,UTC,HH:mm:ss}
-->false: -action Notification on Screen: {duration*1000,dateformat,timezone,UTC,mm:ss}

..or create the text in an action Script:

Code: Select all

if(duration>60*60)
{
   text =  "{duration*1000,dateformat,timezone,UTC,HH:mm:ss}";
}
else
{
   text =  "{duration*1000,dateformat,timezone,UTC,mm:ss}";
}

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Time duration as ##:##:## in a phone call flow

Post by MURTUMA » 24 Feb 2014 23:38

It's solved. Thank you a lot!

Post Reply