Talk:LlGetWallclock

From Second Life Wiki
Jump to navigation Jump to search

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)