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

12
LINES

< > BotCompany Repo | #1019448 - renderHowLongAgo

JavaX fragment (include)

1  
sS renderHowLongAgo(long timestamp) {
2  
  if (timestamp == 0) ret "never";
3  
  int seconds = howManySecondsAgo(timestamp);
4  
  if (seconds <= 0) ret "just now";
5  
  if (seconds < 60) ret n2(seconds, "second") + " ago";
6  
  int minutes = iround(seconds/60.0);
7  
  if (minutes < 60) ret n2(minutes, "minute") + " ago";
8  
  int hours = iround(minutes/60.0);
9  
  if (hours < 24) ret n2(hours, "hour") + " ago";
10  
  int days = iround(hours/24.0);
11  
  ret n2(days, "day") + " ago";
12  
}

Author comment

Began life as a copy of #1019446

download  show line numbers  debug dex   

Travelled to 10 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz

No comments. add comment

Snippet ID: #1019448
Snippet name: renderHowLongAgo
Eternal ID of this version: #1019448/6
Text MD5: c05b0f7c7eb869423787d0131554241a
Author: stefan
Category: javax / calendar
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-04 16:51:55
Source code size: 468 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 116 / 144
Version history: 5 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1019448 & http://1019448.tinybrain.de