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.

sclass WithTimestamp<A> extends Var<A> {
  long timestamp;
  
  Timestamp getTimestamp aka timestamp aka timeStamp() { ret timestamp == 0 ? null : Timestamp(timestamp); }
  
  *() {}
  *(long *timestamp, A value) { super(value); }
  *(A value) { this(now(), value); }
  
  Timestamp timestampObj() { ret timestamp == 0 ? null : Timestamp(timestamp); }
  
  long unixDate() { ret timestamp; }
  
  toString { ret toStringWithTimestamp(super.toString()); }
  S toStringQuoted() { ret toStringWithTimestamp(quote(super.toString())); }
  
  S toStringWithTimestamp(S s) { ret s + " at " + localDateWithSeconds(timestamp); }
  
  bool olderThanMinutes(double minutes) { ret elapsedMinutes_timestamp(timestamp) >= minutes; }
  bool olderThanSeconds(double seconds) { ret elapsedSeconds_timestamp(timestamp) >= seconds; }
}

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: 304 / 750
Version history: 16 change(s)
Referenced in: [show references]