Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Time and MOD (https://forums.graalonline.com/forums/showthread.php?t=134265342)

sssssssssss 12-20-2011 11:21 PM

Time and MOD
 
I have this, and the seconds and mins are going right, but its almost like the hours, days, and year aren't MOD at all, being it shows up 797 hours and 51 days and 1 year and there are definitely not that many seconds.

I was just trying to calculate the seconds up to years, without showing more than an actual min, hour, day, week, and year, in a year, allowed.

PHP Code:

function configureOnlinetime(time) {
  
//calculate time frames
  
temp.seconds int(time 60);
  
temp.minutes int((time 60) % 60);
  
temp.hours int((time 3600) % 3600);
  
temp.days int((time 86400) % 86400);
  
temp.weeks int((time 604800) % 604800);
  
temp.years int((time 3153600) % 3153600);
  
//display time
  
Profile_TextEdit23.text = @ years " yrs," weeks 
    
" wks," days " days," 
    
hours " hrs," minutesro " mins," 
    
seconds " secs";



time = the seconds i have.

callimuc 12-20-2011 11:25 PM

Quote:

Originally Posted by sssssssssss (Post 1678827)
PHP Code:

"..." minutesro "..." 


Off topic: shouldn´t it be minutes?

Tolnaftate2004 12-20-2011 11:27 PM

PHP Code:

temp.hours int(time/3600 1) % 12 

note: 12 (or 24), not 3600.

&c.

sssssssssss 12-20-2011 11:29 PM

It should be minutes, i changed it after posting. What would days, weeks and years mod by? i thought it was the number of seconds in them but i guess not. :x And for my learning, why 12 for hours?

Tolnaftate2004 12-20-2011 11:33 PM

Quote:

Originally Posted by sssssssssss (Post 1678834)
It should be minutes, i changed it after posting. What would days, weeks and years mod by? i thought it was the number of seconds in them but i guess not. :x And for my learning, why 12 for hours?

7 days in a week, so maybe mod days by 7. Approximately 52 weeks in a year, so I'd mod by 52 (although who reports weeks?). Don't mod years. There's no limit for years... I mean unless you want to do decades or millenia or something...
12 (or 24) is for hours in a day. You've already converted from seconds to hours (by dividing by 3600), so you're now working with FULL hours, which you want to cap at 12 (or 24). I think 24 is more appropriate for what you're trying to do here, so mod by 24 (because there are 24 in a day, you know).

e: I didn't read carefully, I thought you were reporting clock time, so the int(x-1)%m+1 hack isn't necessary.

sssssssssss 12-20-2011 11:36 PM

lol xD thanks. I should have known that.


All times are GMT +2. The time now is 06:34 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.