Talk:LlGetWallclock

From Second Life Wiki
Revision as of 21:25, 19 May 2012 by Strife Onizuka (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

I simplified the example code to calculate hours, minutes and seconds. The old code was:

   integer seconds = now % 60;
   integer minutes = ((now - seconds) % 3600) / 60;
   integer hours = (now - minutes - seconds) / 3600;

If it were necessary to subtract the odd minutes and seconds before dividing, then the hour calculation above would be incorrect - the formula for hours would have to be

   integer hours = (now - 60 * minutes - seconds) / 3600;

However, since integer division truncates the fractional part of the quotient, there's no need to subtract anything. This code will work just as well:

   integer seconds = now % 60;
   integer minutes = (now / 60) % 60;
   integer hours = now / 3600;

Montavious Peccable 00:16, 18 May 2012 (PDT)

Good catch. -- Strife (talk|contribs) 21:25, 19 May 2012 (PDT)