recreate javascript date object from the given oDateValues. In case of oDateValue.valid == false, null value will be returned
187520
function(oDateValue, sCalendarType, bUTC, bStrict) {
		var oDate,
			iYear = typeof oDateValue.year === "number" ? oDateValue.year : 1970;

		if (oDateValue.valid) {
			if (bUTC || oDateValue.tzDiff !== undefined) {
				oDate = UniversalDate.getInstance(new Date(0), sCalendarType);
				oDate.setUTCEra(oDateValue.era || UniversalDate.getCurrentEra(sCalendarType));
				oDate.setUTCFullYear(iYear);
				oDate.setUTCMonth(oDateValue.month || 0);
				oDate.setUTCDate(oDateValue.day || 1);
				oDate.setUTCHours(oDateValue.hour || 0);
				oDate.setUTCMinutes(oDateValue.minute || 0);
				oDate.setUTCSeconds(oDateValue.second || 0);
				oDate.setUTCMilliseconds(oDateValue.millisecond || 0);
				if (bStrict && (oDateValue.day || 1) !== oDate.getUTCDate()) {
					// check if valid date given - if invalid, day is not the same (31.Apr -> 1.May)
					oDateValue.valid = false;
					oDate = undefined;
				} else {
					if (oDateValue.tzDiff) {
						// Set TZDiff after checking for valid day, as it may switch the day as well
						oDate.setUTCMinutes((oDateValue.minute || 0) + oDateValue.tzDiff);
					}
					if (oDateValue.week !== undefined  && (oDateValue.month === undefined || oDateValue.day === undefined)) {
						//check that the week is only set if the day/month has not been set, because day/month have higher precedence than week
						oDate.setUTCWeek({
							year: oDateValue.weekYear || oDateValue.year,
							week: oDateValue.week
						});

						//add the dayNumberOfWeek to the current day
						if (oDateValue.dayNumberOfWeek !== undefined) {
							oDate.setUTCDate(oDate.getUTCDate() + oDateValue.dayNumberOfWeek - 1);
						}
					}
				}
			} else {
				oDate = UniversalDate.getInstance(new Date(1970, 0, 1, 0, 0, 0), sCalendarType);
				oDate.setEra(oDateValue.era || UniversalDate.getCurrentEra(sCalendarType));
				oDate.setFullYear(iYear);
				oDate.setMonth(oDateValue.month || 0);
				oDate.setDate(oDateValue.day || 1);
				oDate.setHours(oDateValue.hour || 0);
				oDate.setMinutes(oDateValue.minute || 0);
				oDate.setSeconds(oDateValue.second || 0);
				oDate.setMilliseconds(oDateValue.millisecond || 0);
				if (bStrict && (oDateValue.day || 1) !== oDate.getDate()) {
					// check if valid date given - if invalid, day is not the same (31.Apr -> 1.May)
					oDateValue.valid = false;
					oDate = undefined;
				} else if (oDateValue.week !== undefined && (oDateValue.month === undefined || oDateValue.day === undefined)) {
					//check that the week is only set if the day/month has not been set, because day/month have higher precedence than week
					oDate.setWeek({
						year: oDateValue.weekYear || oDateValue.year,
						week: oDateValue.week
					});

					//add the dayNumberOfWeek to the current day
					if (oDateValue.dayNumberOfWeek !== undefined) {
						oDate.setDate(oDate.getDate() + oDateValue.dayNumberOfWeek - 1);
					}
				}
			}

			if (oDateValue.valid) {
				oDate = oDate.getJSDate();
				return oDate;
			}
		}

		return null;
	}
516584
private static Date getDateOrNull(JSONObject obj, String field)
			throws JSONException {
		String dateStr = JsonInput.getStringOrNull(obj, field);
		if (dateStr == null)
			return null;
		try {
			if (dateStr.length() >= 5 && dateStr.charAt(4) == '/') {
				return RedmineDateUtils.FULL_DATE_FORMAT.get().parse(dateStr);
			}
			if (dateStr.endsWith("Z")) {
				dateStr = dateStr.substring(0, dateStr.length() - 1)
						+ "GMT-00:00";
			} else {
				final int inset = 6;
				if (dateStr.length() <= inset)
					throw new JSONException("Bad date value " + dateStr);
				String s0 = dateStr.substring(0, dateStr.length() - inset);
				String s1 = dateStr.substring(dateStr.length() - inset,
						dateStr.length());
				dateStr = s0 + "GMT" + s1;
			}
			return RedmineDateUtils.FULL_DATE_FORMAT_V2.get().parse(dateStr);
		} catch (ParseException e) {
			throw new JSONException("Bad date value " + dateStr);
		}
	}
188585
def _serialize_date(value):
    """"""
    if not isinstance(value, date):
        raise ValueError(u'The received object was not a date: '
                         u'{} {}'.format(type(value), value))
    return value.isoformat()
411285
public static Time convertDateToTime(Date date, Time elseValue) {
        return Checker.isNull(date) ? elseValue : new Time(date.getTime());
    }
219655
function coerceDate (value) {
  if (!(value instanceof Date)) {
    // Is this how you raise a 'field error'?
    throw new Error('Field error: value is not an instance of Date')
  }
  if (isNaN(value.getTime())) {
    throw new Error('Field error: value is an invalid Date')
  }
  return value.toJSON()
}
536354
function getValidDate (y, m, d, h, i, s, ms) {
  var date = new Date(y, m - 1, d, h, i, s, ms);
  if (
      y  === date.getFullYear()  &&
      m  === date.getMonth() + 1 &&
      d  === date.getDate()      &&
      h  === date.getHours()     &&
      i  === date.getMinutes()   &&
      s  === date.getSeconds()   &&
      ms === date.getMilliseconds()
  ) {
    return date;
  } else {
    return null;
  }
}
645602
public static LocalDate parse(String date) {
		if (StringUtils.isEmpty(date)) return null;
		try {
			return parse_(date);
		} catch (DateTimeParseException x) {
			return InvalidValues.createInvalidLocalDate(date);
		}
	}
866187
function() {
        var _date = {
            year: 			0,
            month: 			1, // stupid JS dates
            day: 			1,
            hour: 			0,
            minute: 		0,
            second: 		0,
            millisecond: 	0
		};

		// Merge data
		TL.Util.mergeData(_date, this.data);

 		// Make strings into numbers
		var DATE_PARTS = TL.Date.DATE_PARTS;

 		for (var ix in DATE_PARTS) {
 		    var x = TL.Util.trim(_date[DATE_PARTS[ix]]);
 		    if (!x.match(/^-?\d*$/)) {
 		        throw new TL.Error("invalid_date_err", DATE_PARTS[ix] + " = '" + _date[DATE_PARTS[ix]] + "'");
 		    }
 		    
			var parsed = parseInt(_date[DATE_PARTS[ix]]);
			if (isNaN(parsed)) {
                parsed = (ix == 4 || ix == 5) ? 1 : 0; // month and day have diff baselines
            }
			_date[DATE_PARTS[ix]] = parsed;
		}

		if (_date.month > 0 && _date.month <= 12) { // adjust for JS's weirdness
			_date.month = _date.month - 1;
		}

		return _date;
    }
66631
function objectToDate(value, sm) {
  var d = Object.keys(value).reduce((x, k) => {
    var term = TERM[k.toLowerCase()];
    var v = value[k];
    if (term && !(term in x) && typeof v === 'number') {
      x[term] = v;
    } else {
      x.err = true;
    }
    return x;
  }, {});

  if (d.err) {
    return null;
  }

  var td = new Date();

  if (!('y' in d ) && !('m' in d ) && !('d' in d )) {
    d.y = td.getFullYear();
    d.m = td.getMonth() + 1;
    d.d = td.getDate();
  }

  var month = 'm' in d ? d.m : sm;
  var year  = 'y' in d ? d.y : td.getFullYear() - (month < sm ? 1 : 0);

  return new Date(
    year,
    month - 1,
    'd'  in d ? d.d  : 1,
    'h'  in d ? d.h  : 0,
    'i'  in d ? d.i  : 0,
    's'  in d ? d.s  : 0,
    'ms' in d ? d.ms : 0
  );
}
788170
function(value) {
		"use strict";

		if (!Array.isArray(value)) {
			value = [value];
		}

		return value.map(function(data) {
			if (data === "now") {
				return new Date();
			}
			if (data instanceof Date) {
				return data;
			}
			return false;
		}).filter(function(d) { return d !== false; });
	}
169431
def DateStringToDateObject(date_string):
  """"""
  # If this becomes a bottleneck date objects could be cached
  if re.match('^\d{8}$', date_string) == None:
    return None
  try:
    return datetime.date(int(date_string[0:4]), int(date_string[4:6]),
                         int(date_string[6:8]))
  except ValueError:
    return None
805283
function datesTransformReviver(key, value) {

    if (key === DATES_FIELD) {
      dates = value
      return null
    }

    if (value && typeof value === 'object' && value.hasOwnProperty(DATES_FIELD)) {
      for (const prop in value) {
        if (value.hasOwnProperty(prop) && dates.indexOf(value[prop]) !== -1) {
          value[prop] = new Date(Number.parseInt(value[prop]))
        }
      }

      datesHolders.push(value)
      dates = undefined
    }

    if (key === '') { //root object
      datesHolders.forEach(datesHolder => {
        delete datesHolder[DATES_FIELD]
      })

      datesHolders = []
    }

    return value
  }
3122
function(object) {
            // three special objects that we want to treat differently
            if(object == null) {
                return "null";
            }
            if(object.constructor == Date) {
                return this.serialize.date.apply(this, [object]);
            }
            if(object.constructor == Array) {
                return this.serialize.array.apply(this, [object]);
            }
            var pieces = ['{'];
            this.level += 1;
            var key, keyJSON, valueJSON;
            
            var addComma = false;
            for(key in object) {
                if(object.hasOwnProperty(key)) {
                    // recursive calls need to allow for sub-classing
                    keyJSON = OpenLayers.Format.JSON.prototype.write.apply(this,
                                                    [key, this.pretty]);
                    valueJSON = OpenLayers.Format.JSON.prototype.write.apply(this,
                                                    [object[key], this.pretty]);
                    if(keyJSON != null && valueJSON != null) {
                        if(addComma) {
                            pieces.push(',');
                        }
                        pieces.push(this.writeNewline(), this.writeIndent(),
                                    keyJSON, ':', this.writeSpace(), valueJSON);
                        addComma = true;
                    }
                }
            }
            
            this.level -= 1;
            pieces.push(this.writeNewline(), this.writeIndent(), '}');
            return pieces.join('');
        }
514816
function isValid(date) {
  return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
}
569988
function(obj) {
    _.forEach(obj, function(val, key) {
      if (_.isString(val)) {
        if (Mixins.isObjectId(val)) {
          obj[key] = Mixins.newObjectId(val);
        } else if (Mixins.isValidISO8601String(val)) {
          obj[key] = new Date(val);
        }
      } else if (_.isDate(val)) {
        obj[key] = val;
      } else if (_.isObject(val)) {
        if (val['$oid']) {
          obj[key] = val['$oid'];
        } else {
          obj[key] = this.cast(val);
        }
      }
    }.bind(this));

    return obj;
  }
66952
function isIso8601DateTimeString(value) {
    var regex = /^(([+-]\d{6}|\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?)(T((([01]\d|2[0-3])(:[0-5]\d)(:[0-5]\d(\.\d{1,3})?)?)|(24:00(:00(\.0{1,3})?)?))(Z|([+-])([01]\d|2[0-3]):([0-5]\d))?)?$/;

    // Verify that it's in ISO 8601 format (via the regex) and that it represents a valid point in time (via Date.parse)
    return regex.test(value) && !isNaN(Date.parse(value));
  }
839415
function (obj) {
		if (typeof obj !== "object" || obj === null) {
			return obj;
		}
		
		if (obj instanceof Date) {
			return new Date(obj.getTime());
		}
		
		if (obj instanceof RegExp) {
			return new RegExp(obj);
		}
		
		if (obj instanceof Array && Object.keys(obj).every(function (k) {
				return !isNaN(k);
			})) {
			return obj.slice(0);
		}
		var _obj = {};
		for (var attr in obj) {
			if (Object.hasOwnProperty.call(obj, attr)) {
				_obj[attr] = swagger.cloneObj(obj[attr]);
			}
		}
		return _obj;
	}