lib/duration.js
function Duration(str) {

  // There must be at least a P
  if(str.length < 1 || str.charAt(0) != 'P') {
    throw new Error('Invalid Duration');
  }

  var duration = str.substr(1);

  if(duration.length < 1) {
    throw new Error('Invalid Duration');
  }

  // 5.3.2 allows for NON normalized durations
  // We assume that if there is a space, it is non-normalized
  if(/\s/.test(duration)) {
    throw new Error('Non normalized durations not implemented');
    //this._parseNonNormalized(duration);
  } else {
    this._parseNormalized(duration);
  }

}
function Duration(str) {

  // There must be at least a P
  if(str.length < 1 || str.charAt(0) != 'P') {
    throw new Error('Invalid Duration');
  }

  var duration = str.substr(1);

  if(duration.length < 1) {
    throw new Error('Invalid Duration');
  }

  // 5.3.2 allows for NON normalized durations
  // We assume that if there is a space, it is non-normalized
  if(/\s/.test(duration)) {
    throw new Error('Non normalized durations not implemented');
    //this._parseNonNormalized(duration);
  } else {
    this._parseNormalized(duration);
  }

}
function Duration ( str ) { // There must be at least a P if ( str . length < 1 || str . charAt ( 0 ) != 'P' ) { throw new Error ( 'Invalid Duration' ) ; } var duration = str . substr ( 1 ) ; if ( duration . length < 1 ) { throw new Error ( 'Invalid Duration' ) ; } // 5.3.2 allows for NON normalized durations // We assume that if there is a space, it is non-normalized if ( / \s / . test ( duration ) ) { throw new Error ( 'Non normalized durations not implemented' ) ; //this._parseNonNormalized(duration); } else { this . _parseNormalized ( duration ) ; } }
A gedcomX Duration
A gedcomX Duration