Libraryless. Click here for Pure Java version (3025L/18K).
1 | ifclass Timestamp |
2 | sS renderHowLongAgo(Timestamp ts) { |
3 | ret renderHowLongAgo(timestampToLong(ts)); |
4 | } |
5 | endif |
6 | |
7 | sS renderHowLongAgo(long timestamp) { |
8 | if (timestamp == 0) ret "never"; |
9 | int seconds = howManySecondsAgo(timestamp); |
10 | if (seconds <= 0) ret "just now"; |
11 | if (seconds < 60) ret n2(seconds, "second") + " ago"; |
12 | int minutes = iround(seconds/60.0); |
13 | if (minutes < 60) ret n2(minutes, "minute") + " ago"; |
14 | int hours = iround(minutes/60.0); |
15 | if (hours < 24) ret n2(hours, "hour") + " ago"; |
16 | int days = iround(hours/24.0); |
17 | ret n2(days, "day") + " ago"; |
18 | } |
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: | 426 / 523 |
Version history: | 6 change(s) |
Referenced in: | [show references] |