Created
August 24, 2017 10:57
-
-
Save shingorow/20b3cf52d1ee375f6972efecd013ef55 to your computer and use it in GitHub Desktop.
JavaScript で秒や分を別の時間単位に変換する ref: http://qiita.com/shingorow/items/62eae5a87c85d1bcd0d2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global) { | |
var TimeConvert = (function () { | |
function TimeConvert() {} | |
TimeConvert.prototype.sec2min = function (time) { | |
var min = Math.floor(time / 60); | |
var sec = time % 60; | |
return { | |
min: min, | |
sec: sec | |
} | |
} | |
TimeConvert.prototype.min2hour = function (time) { | |
var hour = Math.floor(time / 60); | |
var min = time % 60; | |
return { | |
hour: hour, | |
min:min | |
} | |
} | |
TimeConvert.prototype.sec2hour = function (time) { | |
var sec = (time % 60) % 60; | |
var min = Math.floor(time / 60) % 60; | |
var hour = Math.floor(time / 3600); | |
return { | |
hour: hour, | |
min: min, | |
sec: sec | |
} | |
} | |
return TimeConvert; | |
})(); | |
global.TimeConvert = TimeConvert; | |
}(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment