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

18
LINES

< > BotCompany Repo | #1019448 // renderHowLongAgo

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

Libraryless. Click here for Pure Java version (3025L/18K).

ifclass Timestamp
sS renderHowLongAgo(Timestamp ts) {
  ret renderHowLongAgo(timestampToLong(ts));
}
endif

sS renderHowLongAgo(long timestamp) {
  if (timestamp == 0) ret "never";
  int seconds = howManySecondsAgo(timestamp);
  if (seconds <= 0) ret "just now";
  if (seconds < 60) ret n2(seconds, "second") + " ago";
  int minutes = iround(seconds/60.0);
  if (minutes < 60) ret n2(minutes, "minute") + " ago";
  int hours = iround(minutes/60.0);
  if (hours < 24) ret n2(hours, "hour") + " ago";
  int days = iround(hours/24.0);
  ret n2(days, "day") + " ago";
}

Author comment

Began life as a copy of #1019446

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019448
Snippet name: renderHowLongAgo
Eternal ID of this version: #1019448/7
Text MD5: b521d940a16198086fa703c7ddd5e5f7
Transpilation MD5: 640d090d4b834ab5edc6bbacb43b0e87
Author: stefan
Category: javax / calendar
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-28 15:47:24
Source code size: 582 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 425 / 521
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1029972 - renderHowLongAgoPlusModified