Skip to content

Instantly share code, notes, and snippets.

View 0xB10C's full-sized avatar
💿

b10c 0xB10C

💿
View GitHub Profile

Keybase proof

I hereby claim:

  • I am 0xb10c on github.
  • I am b10c (https://keybase.io/b10c) on keybase.
  • I have a public key whose fingerprint is 470B 847C 88D0 4928 77B7 F15D E462 234D D056 4D4A

To claim this, I am signing this object:

@0xB10C
0xB10C / intToDHHMMSS.js
Created August 13, 2017 21:38
A function that converts an integer (seconds) to a DHHMMSS string.
String.prototype.toDHHMMSS = function () {
var sec_num = parseInt(this, 10);
var days = Math.floor(sec_num / 86400)
var hours = Math.floor((sec_num - (days * 86400)) / 3600);
var minutes = Math.floor(((sec_num - (days * 86400)) - (hours * 3600)) / 60);
var seconds = sec_num - (days * 86400) - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}