convert unix time - SLUniverse Forums
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » convert unix time

Scripting Discuss scripting and programming for SL and other platforms

LinkBack Thread Tools Display Modes
Old 03-20-2017, 06:45 PM   #1 (permalink)
Junior Member
Join Date: Mar 2017
Posts: 2
convert unix time

Hi, can somebody help fix this code from a rentbox please,

it says my timeleft is:
6 weeks 42 days 17 hours 34 mins

their realy is 42 days in total, but if it says thiers 6 weeks then thiers no need for It to mention the days unless their was 6 weeks and 1 day 17 hours 34 mins for example

string ts2Days(integer unixExpiration)
    integer seconds = unixExpiration - llGetUnixTime(); integer weeks = seconds / 604800;
    integer days = seconds / 86400; integer hours = (seconds % 86400) / 3600;
    integer mins = (seconds % 3600) / 60; string time = "";
    if (weeks) { time += (string)weeks + " week"; if (~-weeks) time += "s"; time += " "; }
    if (days) { time += (string)days + " day"; if (~-days) time += "s"; time += " "; }
    if (hours) { time += (string)hours + " hour"; if (~-hours) time += "s"; time += " "; }
    if (mins) { time += (string)mins + " min"; if (~-mins) time += "s"; }
    if (days < 4) return time + ",EXPIRING"; else if (days > 6) return time + ",SUPER";
    else return time + ",OK";
    return time;
Devone is offline   Reply With Quote
Old 03-20-2017, 07:29 PM   #2 (permalink)
That Bitch

*SLU Supporter*
Void's Avatar
Innocent as far as you know
Join Date: Nov 2011
Location: Online
Posts: 14,947
My Mood:
SL Join Date: late 04 original account, mid 05 current
days = (seconds % 604800) / 86400
- These eyes can do more than see
Originally Posted by Cajsa Lilliehook View Post
It's not enough to care about liberty if the only liberty you care about is your own.
Originally Posted by Jupiter Firelyte View Post
Why doesn't anyone ever ask, "What is the real meaning of the winter solstice?"
Originally Posted by Eboni Khan View Post
Thanks for being passive agressive.
Void is offline   Reply With Quote
1 User Laughed:
2 Users Agreed:
Old 03-20-2017, 07:29 PM   #3 (permalink)
Junior Member
Twisted Pharaoh's Avatar
Along with Athena, move also your hand
Join Date: Feb 2010
Posts: 2,205
My Mood:
SL Join Date: Yesterday
integer days = (seconds % 604800) / 86400;
Originally Posted by Chuang Tzu
If he who bursts out in anger is not really angry, then his anger is an outburst of nonanger. If he who launches into action is not really acting, then his action is a launching into inaction. He who wishes to be still must calm his energies; he who wishes to be spiritual must compose his mind; he who in his actions wishes to hit the mark must go along with what he cannot help doing. Those things that you cannot help doing - they represent the Way of the sage.
Twisted Pharaoh is offline   Reply With Quote
Old 03-20-2017, 08:53 PM   #4 (permalink)
Senior Member
LoriClaremont's Avatar
This space for rent
Join Date: Jan 2011
Location: San Francisco area
Posts: 653
My Mood:
SL Join Date: 5/30/2009
Client: Firestorm
Subtract the weeks from the days:

if (weeks) { days -= (7 * weeks); }

ETA: Ooo, or what Twisted and Void said will do it in one step.
LoriClaremont is offline   Reply With Quote
Old 03-21-2017, 03:10 PM   #5 (permalink)
Emergency Mustelid
Argent Stonecutter's Avatar
Join Date: Sep 2009
Posts: 20,378
Speaking of UNIX time:

Take the Traders' method of timekeeping. The frame corrections were incredibly complex - and down at the very bottom of it was a little program that ran a counter. Second by second, the Qeng Ho counted from the instant that a human had first set foot on Old Earth's moon. But if you looked at it still more closely ... the starting instant was actually about fifteen million seconds later, the 0-second of one of Humankind's first computer operating systems.
A Deepness in the Sky, Vernor Vinge.
Argent Stonecutter -- Skyhook Station -- Coonspiracy Store

"And now I'm going to show you something really cool."

The previous is a cybernetic datum published - in direct contravention of DoD Regulation #229RR3X3 - as being conducive to the physical, psychological and/or social well-being of the population.
Argent Stonecutter is offline   Reply With Quote
2 Users Like This:

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On