Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1015652 // machineTime - a time value that is guaranteed to increase; starts as equal to now() and is adjusted when system clock changes backwards

JavaX fragment (include)

1  
scope machineTime.
2  
3  
static long #last;
4  
5  
static long machineTime() {
6  
  lock #lock;
7  
  long offset = machineTimeOffset();
8  
  long value = now()+offset;
9  
  if (value < last) {
10  
    long newOffset = offset + last-value+1000;
11  
    setMachineTimeOffset(newOffset);
12  
    logQuoted(javaxDataDir("machine-time-events"), "Machine time change occurred!! " + offset + " -> " + newOffset + " at " + now() + " (" + localDateWithMilliseconds() + ")");
13  
    offset = newOffset;
14  
    value = now()+offset;
15  
  }
16  
  last = value;
17  
  ret value;
18  
}
19  
20  
end scope

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015652
Snippet name: machineTime - a time value that is guaranteed to increase; starts as equal to now() and is adjusted when system clock changes backwards
Eternal ID of this version: #1015652/4
Text MD5: 9bc2d3ad0820d0eb614ce19e2103f5ab
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-20 15:54:22
Source code size: 545 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 311 / 341
Version history: 3 change(s)
Referenced in: [show references]