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

16
LINES

< > BotCompany Repo | #1030677 // formatHoursMinutesColonSeconds - hour is optional

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

Libraryless. Click here for Pure Java version (9572L/52K).

1  
sS formatHoursMinutesColonSeconds(double seconds) {
2  
  ret formatHoursMinutesColonSeconds(toMS(seconds));
3  
}
4  
5  
sS formatHoursMinutesColonSeconds(long ms) {
6  
  long seconds = iround(toSeconds(ms));
7  
  long hours = seconds/(60*60);
8  
  S s = "";
9  
  if (hours > 0) {
10  
    s = hours + ":";
11  
    seconds -= hours*60*60;
12  
    s += formatInt(seconds/60, 2);
13  
  } else
14  
    s = str(seconds/60);
15  
  ret s + ":" + formatInt(mod(seconds, 60), 2);
16  
}

Author comment

Began life as a copy of #1020551

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030677
Snippet name: formatHoursMinutesColonSeconds - hour is optional
Eternal ID of this version: #1030677/3
Text MD5: 286c32d1a7a3cae5609a167add400364
Transpilation MD5: 846ae906f2d13989aabd95c4d021087d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-04 20:39:56
Source code size: 438 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 124 / 185
Version history: 2 change(s)
Referenced in: [show references]