{"size": 645, "ext": "js", "max_stars_repo_path": "formats/time.js", "max_stars_repo_name": "Download/ulogv2", "max_stars_repo_stars_event_min_datetime": "2019-07-13T09:06:35.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-13T09:06:35.000Z", "max_issues_repo_path": "formats/time.js", "max_issues_repo_name": "Download/ulogv2", "max_issues_repo_issues_event_min_datetime": "2020-07-17T17:39:33.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T15:07:58.000Z", "max_forks_repo_path": "formats/time.js", "max_forks_repo_name": "Download/ulogv2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 33.9473684211, "max_line_length": 106, "alphanum_fraction": 0.5224806202}
var pad = require('./col')

module.exports = function time(cfg) {
  var parts = (cfg || '').split(':').map(function(x){
    return (
      x.indexOf('h') === 0 ? function(d){return pad(pad.LEFT, d.getHours(), x == 'hh' ? 2 : 1, '0')} :
      x.indexOf('m') === 0 ? function(d){return pad(pad.LEFT, d.getMinutes(), x == 'mm' ? 2 : 1, '0')} :
      x.indexOf('s') === 0 ? function(d){return pad(pad.LEFT, d.getSeconds(), x == 'ss' ? 2 : 1, '0')} : d
    )
  })
  
  return function(rec){
    rec.time = rec.time || new Date().getTime()
    var d = new Date(rec.time)
    return parts.map(function(part){
      return part(d)
    }).join(':')
  }
}