Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- window.format_time_short = function(seconds) {
- var secondsPerMinute = 60;
- var secondsPerHour = 3600;
- var secondsPerDay = 86400;
- var txt = "";
- seconds = Math.round(seconds);
- if (seconds < 120) {
- var _minutes = Math.floor(seconds / secondsPerMinute);
- if (_minutes) {
- txt += _minutes + GT.time.m;
- txt += " ";
- seconds -= _minutes * secondsPerMinute;
- }
- txt += seconds < 10 ? "0" + seconds : seconds;
- return txt + GT.time.s;
- }
- var days = Math.floor(seconds / secondsPerDay);
- if (days) {
- txt += days + GT.time.d;
- seconds -= days * secondsPerDay;
- }
- var hours = Math.floor(seconds / secondsPerHour);
- if (hours) {
- if (days)
- txt += " ";
- txt += hours + GT.time.h;
- seconds -= hours * secondsPerHour;
- }
- var minutes = Math.floor(seconds / secondsPerMinute);
- if (minutes) {
- if (hours)
- txt += " ";
- txt += minutes + GT.time.m;
- }
- return txt;
- };});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement