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: 261 / 704
Version history: 16 change(s)
Referenced in: #1026688 - WithReasoning
#1027535 - withTimestamp
#1029452 - WithDuration
#1031842 - WithCount [int]
#1032306 - WithURL
#1033103 - IWithSideValue
#1033104 - WithSideValue - pair of a main value (.get() or !) and a side value (.sideValue()), both of arbitrary type
#1033609 - WithGlobalID
#1033911 - WithToolTip
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)