src/js2dt.js
function convertDateType (data) {
  if (!(data.type === 'string' && data.pattern)) {
    return data
  }
  const pattern = data.pattern
  delete data.pattern
  switch (pattern) {
    case constants.dateOnlyPattern:
      data['type'] = 'date-only'
      break
    case constants.timeOnlyPattern:
      data['type'] = 'time-only'
      break
    case constants.dateTimeOnlyPattern:
      data['type'] = 'datetime-only'
      break
    case constants.RFC3339DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC3339
      break
    case constants.RFC2616DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC2616
      break
    default:
      data['pattern'] = pattern
  }
  return data
}
function convertDateType (data) {
  if (!(data.type === 'string' && data.pattern)) {
    return data
  }
  const pattern = data.pattern
  delete data.pattern
  switch (pattern) {
    case constants.dateOnlyPattern:
      data['type'] = 'date-only'
      break
    case constants.timeOnlyPattern:
      data['type'] = 'time-only'
      break
    case constants.dateTimeOnlyPattern:
      data['type'] = 'datetime-only'
      break
    case constants.RFC3339DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC3339
      break
    case constants.RFC2616DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC2616
      break
    default:
      data['pattern'] = pattern
  }
  return data
}
function convertDateType ( data ) { if ( ! ( data . type === 'string' && data . pattern ) ) { return data } const pattern = data . pattern delete data . pattern switch ( pattern ) { case constants . dateOnlyPattern : data [ 'type' ] = 'date-only' break case constants . timeOnlyPattern : data [ 'type' ] = 'time-only' break case constants . dateTimeOnlyPattern : data [ 'type' ] = 'datetime-only' break case constants . RFC3339DatetimePattern : data [ 'type' ] = 'datetime' data [ 'format' ] = constants . RFC3339 break case constants . RFC2616DatetimePattern : data [ 'type' ] = 'datetime' data [ 'format' ] = constants . RFC2616 break default : data [ 'pattern' ] = pattern } return data }
Change JSON date type of data to valid RAML date type.

@param  {Object} data
@returns  {Object}
Change JSON date type of data to valid RAML date type .