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

16
LINES

< > BotCompany Repo | #1030677 // formatHoursMinutesColonSeconds - format a duration. hour is optional

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

Transpiled version (9572L) is out of date.

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 - format a duration. hour is optional
Eternal ID of this version: #1030677/4
Text MD5: 286c32d1a7a3cae5609a167add400364
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-08-18 18:54:08
Source code size: 438 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 291
Version history: 3 change(s)
Referenced in: [show references]