<commit_before>/**
 * @class inputEx.DateField
 *
 * options: 
 *		- dateFormat: default to 'm/d/Y'
 */
inputEx.DateField = function(options) {
   if(!options) { var options = {}; }
   if(!options.messages) { options.messages = {}; }
	if(!options.dateFormat) {options.dateFormat = 'm/d/Y'; }
	options.messages.invalid = inputEx.messages.invalidDate;
	inputEx.DateField.superclass.constructor.call(this,options);
};
YAHOO.lang.extend(inputEx.DateField, inputEx.Field, {
   
   validate: function() {
      
      var value = this.el.value;
      var ladate = value.split("/");
      if( ladate.length != 3) { return false; }
      if ( isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) { return false; }
   	var formatSplit = this.options.dateFormat.split("/");
   	var d = parseInt(ladate[ formatSplit.indexOf('d') ],10);
   	var Y = parseInt(ladate[ formatSplit.indexOf('Y') ],10);
   	var m = parseInt(ladate[ formatSplit.indexOf('m') ],10)-1;
      var unedate = new Date(Y,m,d);
      var annee = unedate.getFullYear();
      return ((unedate.getDate() == d) && (unedate.getMonth() == m) && (annee == Y));
   },
   
   render: function() {
   	inputEx.DateField.superclass.render.call(this);
   },
   

   setValue: function(val) {

      // Don't try to parse a date if there is no date
      if( val === '' ) {
         this.el.value = '';
         return;
      }<commit_msg>Pas de date a moins de 4 chiffres<commit_after>/**
 * @class inputEx.DateField
 *
 * options: 
 *		- dateFormat: default to 'm/d/Y'
 */
inputEx.DateField = function(options) {
   if(!options) { var options = {}; }
   if(!options.messages) { options.messages = {}; }
	if(!options.dateFormat) {options.dateFormat = 'm/d/Y'; }
	options.messages.invalid = inputEx.messages.invalidDate;
	inputEx.DateField.superclass.constructor.call(this,options);
};
YAHOO.lang.extend(inputEx.DateField, inputEx.Field, {
   
   validate: function() {
      
      var value = this.el.value;
      var ladate = value.split("/");
      if( ladate.length != 3) { return false; }
      if ( isNaN(parseInt(ladate[0])) || isNaN(parseInt(ladate[1])) || isNaN(parseInt(ladate[2]))) { return false; }
   	var formatSplit = this.options.dateFormat.split("/");
      if (ladate[ formatSplit.indexOf('Y') ].length!=4) { return false; } // Avoid 3-digits years...
   	var d = parseInt(ladate[ formatSplit.indexOf('d') ],10);
   	var Y = parseInt(ladate[ formatSplit.indexOf('Y') ],10);
   	var m = parseInt(ladate[ formatSplit.indexOf('m') ],10)-1;
      var unedate = new Date(Y,m,d);
      var annee = unedate.getFullYear();
      return ((unedate.getDate() == d) && (unedate.getMonth() == m) && (annee == Y));
   },
   
   render: function() {
   	inputEx.DateField.superclass.render.call(this);
   },
   

   setValue: function(val) {

      // Don't try to parse a date if there is no date
      if( val === '' ) {
         this.el.value = '';
         return;
      }
{'fraction_non_alphanumeric': 0.17933130699088146, 'fraction_numerical': 0.008443093549476529, 'mean_word_length': 3.068681318681319, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7112430', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1017, 'n_words': 204}