balance time

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

balance time

Post by Rafi4 » 19 Dec 2018 16:27

hi Martin and all
I have set a reminder for ten minutes. four minutes past. how can I get balance minutes of six minutes.

script:
global_10 = addMinutes(getDate(),10); current time is 10.00 a.m after 10.04 a.m I want to get balance minutes of 6.
how can I? and how can I set percentage to global_10?

thanks from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: balance time

Post by Desmanto » 19 Dec 2018 16:55

Just deduct the global_10 from current time.

Code: Select all

balance = global_10 - getDate();
You will get 360000 (360 seconds, or 6 minutes).

You can then convert it duration as pointed by anuraag in other thread.

Code: Select all

balance = getDurationString(balance);
Or

Code: Select all

balance = "{balance,dateformat,timezone,UTC,HH:mm:ss}"
If you need percentage, you have to save the starting point time when you add the minutes. If you have a fixed 10 minutes range, just simply divide that 6 minutes to 10 minutes. (360000 / 600000), then times 100% to get it percentage.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply