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

21
LINES

< > BotCompany Repo | #1026686 // WithTimestamp

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (4307L) is out of date.

1  
sclass WithTimestamp<A> extends Var<A> {
2  
  long timestamp;
3  
  
4  
  Timestamp getTimestamp aka timestamp aka timeStamp() { ret timestamp == 0 ? null : Timestamp(timestamp); }
5  
  
6  
  *() {}
7  
  *(long *timestamp, A value) { super(value); }
8  
  *(A value) { this(now(), value); }
9  
  
10  
  Timestamp timestampObj() { ret timestamp == 0 ? null : Timestamp(timestamp); }
11  
  
12  
  long unixDate() { ret timestamp; }
13  
  
14  
  toString { ret toStringWithTimestamp(super.toString()); }
15  
  S toStringQuoted() { ret toStringWithTimestamp(quote(super.toString())); }
16  
  
17  
  S toStringWithTimestamp(S s) { ret s + " at " + localDateWithSeconds(timestamp); }
18  
  
19  
  bool olderThanMinutes(double minutes) { ret elapsedMinutes_timestamp(timestamp) >= minutes; }
20  
  bool olderThanSeconds(double seconds) { ret elapsedSeconds_timestamp(timestamp) >= seconds; }
21  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026686
Snippet name: WithTimestamp
Eternal ID of this version: #1026686/17
Text MD5: 0b8fbcc8beca4525f23b0365e6d2998e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-03-14 14:54:17
Source code size: 836 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 362 / 819
Version history: 16 change(s)
Referenced in: [show references]