Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@filerobot/utils / lib / formatSeconds.js
Size: Mime:
/**
 * Takes an Integer value of seconds (e.g. 83) and converts it into a human-readable formatted string (e.g. '1:10:23').
 *
 * @param {Integer} seconds
 * @returns {string} the formatted seconds (e.g. '1:10:23' for 1 hour, 10 minutes and 23 seconds)
 *
 */
export default function formatSeconds(seconds) {
  if (!seconds) return;
  var formattedHours = Math.floor(seconds / 3600);
  var formattedMinutes = Math.floor(seconds % 3600 / 60);
  var formattedSeconds = Math.floor(seconds % 3600 % 60);
  return "".concat(formattedHours ? "".concat(formattedHours, ":") : '').concat(String(formattedMinutes).padStart(2, 0), ":").concat(String(Math.floor(formattedSeconds % 60)).padStart(2, 0));
}