<commit_before>/*jshint laxcomma: true, smarttabs: true, node: true*/
'use strict';
/**
 * Field class for dealing for formatted Dates with out Time information
 * @module tastypie/fields/date
 * @author <NAME>
 * @since 0.5.0
 * @requires tastypie/lib/class
 * @requires tastypie/lib/fields/api
 */

var util           = require( 'util' )
  , boom           = require( 'boom' )
  , strftime       = require( 'mout/date/strftime' )
  , isString       = require( 'mout/lang/isString'  )
  , Class          = require( '../class' )
  , ApiField       = require('./api')
  , DATE_REGEX     = /^([0-9]{4})-?([0-9]{2})-?([0-9]{2})$/
  , sample         = new Date('Jan 31, 1960')
  , DateField
  ;

/**
 * @constructor
 * @alias module:tastypie/fields/date
 * @extends module:tastypie/fields/api
 * @param {Object} [options]
 * @param {String} [options.format=%F]
 * @example var x = new tastypie/fields/date();
 */
DateField = new Class({
	inherits: ApiField
	,options:{
		format:'%F'
	   ,help:'Converts Date object to and from YYYY-MM-DD'
	}

	,convert: function convert( value ){
		if( !value ){
			return value;
		}

		if( isString( value ) ){
			var valid = value.match( DATE_REGEX );
			if( !valid ){
				this.emit('error', boom.create(400, util.format( "Invalid Date String for field %s: %s", this.options.name, value ) ) );
			}<commit_msg>removing unecessary if statement<commit_after>/*jshint laxcomma: true, smarttabs: true, node: true*/
'use strict';
/**
 * Field class for dealing for formatted Dates with out Time information
 * @module tastypie/fields/date
 * @author <NAME>
 * @since 0.5.0
 * @requires tastypie/lib/class
 * @requires tastypie/lib/fields/api
 */

var util           = require( 'util' )
  , boom           = require( 'boom' )
  , strftime       = require( 'mout/date/strftime' )
  , isString       = require( 'mout/lang/isString'  )
  , Class          = require( '../class' )
  , ApiField       = require('./api')
  , DATE_REGEX     = /^([0-9]{4})-?([0-9]{2})-?([0-9]{2})$/
  , sample         = new Date('Jan 31, 1960')
  , DateField
  ;

/**
 * @constructor
 * @alias module:tastypie/fields/date
 * @extends module:tastypie/fields/api
 * @param {Object} [options]
 * @param {String} [options.format=%F]
 * @example var x = new tastypie/fields/date();
 */
DateField = new Class({
	inherits: ApiField
	,options:{
		format:'%F'
	   ,help:'Converts Date object to and from YYYY-MM-DD'
	}

	,convert: function convert( value ){
		if( value && isString( value ) ){
			var valid = value.match( DATE_REGEX );
			if( !valid ){
				this.emit('error', boom.create(400, util.format( "Invalid Date String for field %s: %s", this.options.name, value ) ) );
			}
{'fraction_non_alphanumeric': 0.17277486910994763, 'fraction_numerical': 0.015706806282722512, 'mean_word_length': 2.9688427299703264, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6770195', 'n_tokens_mistral': 1005, 'n_tokens_neox': 938, 'n_words': 230}