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

25
LINES

< > BotCompany Repo | #1031686 // TimestampRange

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

Libraryless. Click here for Pure Java version (9999L/55K).

srecord TimestampRange(Timestamp start, Timestamp end) is Comparable<TimestampRange> {
  *(long start, long end) {
    this(Timestamp(start), Timestamp(end));
  }
  
  Timestamp start aka startTime() { ret start; }
  Timestamp end aka endTime() { ret end; }
  
  selfType start aka startTime(Timestamp start) { this.start = start; this; }
  selfType end aka endTime(Timestamp end) { this.end = end; this; }
  
  bool complete() { ret start != null && end != null; }
  
  Duration duration() { ret !complete() ? null : end.minusAsDuration(start); }
  
  long length() { ret !complete() ? 0 : end.unixDate()-start.unixDate(); }
  
  toString { ret start + " to " + end; }
  
  public int compareTo(TimestampRange r) {
    ret cmp(start, r.start);
  }
  
  L<Timestamp> toList() { ret ll(start, end); }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031686
Snippet name: TimestampRange
Eternal ID of this version: #1031686/13
Text MD5: 28b9b53be3f844d2102b6fc0ec9556b4
Transpilation MD5: b4ed499c379da215e2224337c7161c93
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-20 22:20:26
Source code size: 825 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 418
Version history: 12 change(s)
Referenced in: [show references]