Convert Seconds to Days, hours and minutes

352 views
Skip to first unread message

Matt

unread,
Feb 21, 2013, 6:44:23 AM2/21/13
to tas...@googlegroups.com
I'm trying to convert the Uptime variable %UPS to days hours and minutes but I'm hitting a few problems.

I can covert it to days (divide by 86400) but this gives me something like 10.865. What I would like to get to is 10 days 4 hours 30 minutes. If I could round up the minutes to whole hours so much the better).

Is there a way of working with remainders in Variables?

Thanks

Matt

TomL

unread,
Feb 21, 2013, 7:43:23 AM2/21/13
to tas...@googlegroups.com
floor(123.456) gives you 123
ceil(123.456) gives you 124
10%3 gives you 1

Hope that helps.

Tom

Pent

unread,
Feb 21, 2013, 7:46:09 AM2/21/13
to Tasker
> I can covert it to days (divide by 86400) but this gives me something like
> 10.865. What I would like to get to is 10 days 4 hours 30 minutes. If I
> could round up the minutes to whole hours so much the better).

Look in the maths library page in the userguide. There's probably an
function to
get rid of the .865 ('int' or similar)

To get hours and minutes:

%partdayseconds = %UPS % 86400 (seconds left after removing the days)
%hours = int( partdayseconds / 3600 )
%parthourseconds = %partdayseconds % 3600 ( seconds left after
removing the hours)
%mins = int( %parthourseconds / 60 )

Pent

Matt

unread,
Feb 21, 2013, 9:42:25 AM2/21/13
to tas...@googlegroups.com
Perfect, just had to replace int with floor and it worked a treat.

Next stop will be the new beta now I've got my Desire S running ICS :)
Reply all
Reply to author
Forward
0 new messages