src/components/clocker/clocker.js
function parseDateString (dateString) {
  // Pass through when a native object is sent
  if (dateString instanceof Date) {
    return dateString
  }
  // Caste string to date object
  if (String(dateString).match(matchers)) {
    // If looks like a milisecond value cast to number before
    // final casting (Thanks to @msigley)
    if (String(dateString).match(/^[0-9]*$/)) {
      dateString = Number(dateString)
    }
    // Replace dashes to slashes
    if (String(dateString).match(/-/)) {
      dateString = String(dateString).replace(/-/g, '/')
    }
    return new Date(dateString)
  } else {
    throw new Error('Couldn\'t cast `' + dateString +
      '` to a date object.')
  }
}
function parseDateString (dateString) {
  // Pass through when a native object is sent
  if (dateString instanceof Date) {
    return dateString
  }
  // Caste string to date object
  if (String(dateString).match(matchers)) {
    // If looks like a milisecond value cast to number before
    // final casting (Thanks to @msigley)
    if (String(dateString).match(/^[0-9]*$/)) {
      dateString = Number(dateString)
    }
    // Replace dashes to slashes
    if (String(dateString).match(/-/)) {
      dateString = String(dateString).replace(/-/g, '/')
    }
    return new Date(dateString)
  } else {
    throw new Error('Couldn\'t cast `' + dateString +
      '` to a date object.')
  }
}
function parseDateString ( dateString ) { // Pass through when a native object is sent if ( dateString instanceof Date ) { return dateString } // Caste string to date object if ( String ( dateString ) . match ( matchers ) ) { // If looks like a milisecond value cast to number before // final casting (Thanks to @msigley) if ( String ( dateString ) . match ( / ^[0-9]*$ / ) ) { dateString = Number ( dateString ) } // Replace dashes to slashes if ( String ( dateString ) . match ( / - / ) ) { dateString = String ( dateString ) . replace ( / - / g , '/' ) } return new Date ( dateString ) } else { throw new Error ( 'Couldn\'t cast `' + dateString + '` to a date object.' ) } }
Parse a Date formatted has String to a native object
Parse a Date formatted has String to a native object