2013-09-02

Curious time calculation

This one has bugged me for a long time, and it's one I've come across a fair bit because it seems to involve a pretty famous in-world rental system. And I wonder exactly how the code works such that this even happens.

So, here's an IM from a rental box, reminding me how long I've got left to pay:


So, according to that, time's up. Rent has run out. The fact that I've even received that means that I'm late paying. Right?

Wrong. I know for certain that there's still 24 hours left. Here's the result of my slapping the box once I got in world and went over to pay that rent:


As you can probably tell, I did that about 1/2 hour after I got the first IM.

I'd love to know what the code looks like such that the calculation can be that wrong.

4 comments:

  1. The only I can think of is that it calculates the remaining time, obtains 1:0:0, and then perhaps of forgetting a copy/paste, it calculates again the hour after a little delay. Not a delay we could perceive, but enough as to make the total of days 0, and finally show 0:0:0.

    Whichever the reason is, it sure has made me blink and wonder. I'd love to know what that part the code looks like, too.

    ReplyDelete
    Replies
    1. Yeah, it's got to be something to do with repeatedly getting a value that should only be got once. As in (pseudo-code):

      time = TimeNow();
      days = CalcDays( time );
      mins = CalcMins( time );
      secs = CalcSecs( time );

      vs:

      days = CalcDays( TimeNow() );
      mins = CalcMins( TimeNow() );
      secs = CalcSecs( TimeNow() );

      Classic mistake that almost never shows a problem, but would be more likely to in SL if a region is running a touch slow. That's all I can think of at the moment.

      Delete
    2. And, yeah, throw in hours in there somewhere too. D'oh!

      Delete
  2. Er... When I've said the hour, I meant, the total of days. My bad.

    PS: The captcha is giving me a hard time, lol *checks if she's still human*

    ReplyDelete