src/components/clocker/clocker.js
function strftime (offsetObject) {
  return function (format) {
    var directives = format.match(/%(-|!)?[A-Z]{1}(:[^]+)?/gi)
    var d2h = false
    if (directives.indexOf('%D') < 0 && directives.indexOf('%H') >= 0) {
      d2h = true
    }
    if (directives) {
      for (var i = 0, len = directives.length; i < len; ++i) {
        var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^]+)?/)
        var regexp = escapedRegExp(directive[0])
        var modifier = directive[1] || ''
        var plural = directive[3] || ''
        var value = null
        var key = null
        // Get the key
        directive = directive[2]
        // Swap shot-versions directives
        if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
          key = DIRECTIVE_KEY_MAP[directive]
          value = Number(offsetObject[key])
          if (key === 'hours' && d2h) {
            value += Number(offsetObject['days']) * 24
          }
        }
        if (value !== null) {
          // Pluralize
          if (modifier === '!') {
            value = pluralize(plural, value)
          }
          // Add zero-padding
          if (modifier === '') {
            if (value < 10) {
              value = '0' + value.toString()
            }
          }
          // Replace the directive
          format = format.replace(regexp, value.toString())
        }
      }
    }
    format = format.replace('%_M1', offsetObject.minutes_1)
      .replace('%_M2', offsetObject.minutes_2)
      .replace('%_S1', offsetObject.seconds_1)
      .replace('%_S2', offsetObject.seconds_2)
      .replace('%_S3', offsetObject.seconds_3)
      .replace('%_H1', offsetObject.hours_1)
      .replace('%_H2', offsetObject.hours_2)
      .replace('%_H3', offsetObject.hours_3)
      .replace('%_D1', offsetObject.days_1)
      .replace('%_D2', offsetObject.days_2)
      .replace('%_D3', offsetObject.days_3)
    format = format.replace(/%%/, '%')
    return format
  }
}
function strftime (offsetObject) {
  return function (format) {
    var directives = format.match(/%(-|!)?[A-Z]{1}(:[^]+)?/gi)
    var d2h = false
    if (directives.indexOf('%D') < 0 && directives.indexOf('%H') >= 0) {
      d2h = true
    }
    if (directives) {
      for (var i = 0, len = directives.length; i < len; ++i) {
        var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^]+)?/)
        var regexp = escapedRegExp(directive[0])
        var modifier = directive[1] || ''
        var plural = directive[3] || ''
        var value = null
        var key = null
        // Get the key
        directive = directive[2]
        // Swap shot-versions directives
        if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) {
          key = DIRECTIVE_KEY_MAP[directive]
          value = Number(offsetObject[key])
          if (key === 'hours' && d2h) {
            value += Number(offsetObject['days']) * 24
          }
        }
        if (value !== null) {
          // Pluralize
          if (modifier === '!') {
            value = pluralize(plural, value)
          }
          // Add zero-padding
          if (modifier === '') {
            if (value < 10) {
              value = '0' + value.toString()
            }
          }
          // Replace the directive
          format = format.replace(regexp, value.toString())
        }
      }
    }
    format = format.replace('%_M1', offsetObject.minutes_1)
      .replace('%_M2', offsetObject.minutes_2)
      .replace('%_S1', offsetObject.seconds_1)
      .replace('%_S2', offsetObject.seconds_2)
      .replace('%_S3', offsetObject.seconds_3)
      .replace('%_H1', offsetObject.hours_1)
      .replace('%_H2', offsetObject.hours_2)
      .replace('%_H3', offsetObject.hours_3)
      .replace('%_D1', offsetObject.days_1)
      .replace('%_D2', offsetObject.days_2)
      .replace('%_D3', offsetObject.days_3)
    format = format.replace(/%%/, '%')
    return format
  }
}
function strftime ( offsetObject ) { return function ( format ) { var directives = format . match ( / %(-|!)?[A-Z]{1}(:[^]+)? / gi ) var d2h = false if ( directives . indexOf ( '%D' ) < 0 && directives . indexOf ( '%H' ) >= 0 ) { d2h = true } if ( directives ) { for ( var i = 0 , len = directives . length ; i < len ; ++ i ) { var directive = directives [ i ] . match ( / %(-|!)?([a-zA-Z]{1})(:[^]+)? / ) var regexp = escapedRegExp ( directive [ 0 ] ) var modifier = directive [ 1 ] || '' var plural = directive [ 3 ] || '' var value = null var key = null // Get the key directive = directive [ 2 ] // Swap shot-versions directives if ( DIRECTIVE_KEY_MAP . hasOwnProperty ( directive ) ) { key = DIRECTIVE_KEY_MAP [ directive ] value = Number ( offsetObject [ key ] ) if ( key === 'hours' && d2h ) { value += Number ( offsetObject [ 'days' ] ) * 24 } } if ( value !== null ) { // Pluralize if ( modifier === '!' ) { value = pluralize ( plural , value ) } // Add zero-padding if ( modifier === '' ) { if ( value < 10 ) { value = '0' + value . toString ( ) } } // Replace the directive format = format . replace ( regexp , value . toString ( ) ) } } } format = format . replace ( '%_M1' , offsetObject . minutes_1 ) . replace ( '%_M2' , offsetObject . minutes_2 ) . replace ( '%_S1' , offsetObject . seconds_1 ) . replace ( '%_S2' , offsetObject . seconds_2 ) . replace ( '%_S3' , offsetObject . seconds_3 ) . replace ( '%_H1' , offsetObject . hours_1 ) . replace ( '%_H2' , offsetObject . hours_2 ) . replace ( '%_H3' , offsetObject . hours_3 ) . replace ( '%_D1' , offsetObject . days_1 ) . replace ( '%_D2' , offsetObject . days_2 ) . replace ( '%_D3' , offsetObject . days_3 ) format = format . replace ( / %% / , '%' ) return format } }
Time string formatter
Time string formatter