Converts Complex objects into primitives
Only conversion at present is for Dates.
19920
function convertOut(contact) {
    var value = contact.birthday;
    if (value !== null) {
        // try to make it a Date object if it is not already
        if (!utils.isDate(value)){
            try {
                value = new Date(value);
            } catch(exception){
                value = null;
            }
        }
        if (utils.isDate(value)){
            value = value.valueOf(); // convert to milliseconds
        }
        contact.birthday = value;
    }
    return contact;
}
1373214
function getDateObject(datetime) {
  var t = datetime instanceof Date ? datetime : new Date(datetime);
  if (!t.getDate()) {
    t = new Date();
  }
  return t;
}
1052300
def _simpleparsefun(date):
    """"""
    if hasattr(date, 'year'):
        return date
    try:
        date = datetime.datetime.strptime(date, '%Y-%m-%d')
    except ValueError:
        date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
    return date
840931
function(date, showSeconds) {
			if(typeof showSeconds === "undefined") {
				showSeconds = true;
			}

			if(!date) {
				date = this.getDateObject();
			}

			var data  = [
				date.getHours(),
				date.getMinutes()			
			];

			if(showSeconds === true) {
				data.push(date.getSeconds());
			}

			return this.digitize(data);
		}
578728
function convertStrItems2Obj(obj) {
	var result = {};
	for (var key in obj) {
		var val = obj[key];
		val = extractTypeAndCast(val);
		convertStrItem2Obj(key, val, result);
	}

	return result;
}
162531
@Nullable
  private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) {
    Object defaultValue = defaultValue(resultClass);

    if (defaultValue == null) {
      // For primitive type, the default value shouldn't be null
      return null;
    }

    return new BasicConverter(defaultValue) {
      @Override
      protected Object convert(String value) throws Exception {
        return valueOf(value, resultClass);
      }
    };
  }
314214
private static Date parse(String date) {
        for (int i = 0; i < fmt.length; i++) {
            try {
                SimpleDateFormat df = new SimpleDateFormat(fmt[i]);
                return df.parse(date);
            } catch (ParseException E) {
                // keep trying
            }
        }
        throw new IllegalArgumentException(date);
    }
1091314
def _deserialize(self, value, attr, obj):
        """"""
        if not self.context.get('convert_dates', True) or not value:
            return value

        value = super(PendulumField, self)._deserialize(value, attr, value)
        timezone = self.get_field_value('timezone')
        target = pendulum.instance(value)

        if (timezone and (text_type(target) !=
                          text_type(target.in_timezone(timezone)))):
            raise ValidationError(
                "The provided datetime is not in the "
                "{} timezone.".format(timezone)
            )

        return target
1163045
private JSONValue datesToJsonArray(Collection<Date> dates) {

        if (null != dates) {
            JSONArray result = new JSONArray();
            for (Date d : dates) {
                result.set(result.size(), dateToJson(d));
            }
            return result;
        }
        return null;
    }
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;
  }
91827
def _parse_dates(self, prop=DATES):
        

        return parse_dates(self._xml_tree, self._data_structures[prop])
131800
def _decode_datetime(obj):
    """"""

    if '__datetime__' in obj:
        obj = datetime.datetime.strptime(obj['as_str'].decode(), "%Y%m%dT%H:%M:%S.%f")
    return obj
432025
public static Date convertDate(Object target) {
        if (target instanceof JsonNode) {
            return convertDate((JsonNode) target);
        }
        DateFormat df = new SimpleDateFormat();
        try {
            return target instanceof Date ? (Date) target
                    : target instanceof Number ? new Date(((Number) target).longValue())
                            : target instanceof String ? df.parse(target.toString()) : null;
        } catch (ParseException e) {
            return null;
        }
    }
302900
private static Class<?>[] convertParameterTypesToPrimitive(Class<?>[] parameterTypes) {
        Class<?>[] converted = new Class<?>[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            Class<?> primitiveWrapperType = PrimitiveWrapper.getPrimitiveFromWrapperType(parameterTypes[i]);
            if (primitiveWrapperType == null) {
                converted[i] = parameterTypes[i];
            } else {
                converted[i] = primitiveWrapperType;
            }
        }
        return converted;
    }
939035
private void _serializeDate(Date date, StringBuilder sb) throws ConverterException {
	_serializeDateTime(new DateTimeImpl(date), sb);
    }
271746
def serialize(obj):
    
    LOGGER.debug('serialize(%s)', obj)

    if isinstance(obj, datetime.date):
        return simplejson.dumps(obj, default=encoders.as_date)

    elif hasattr(obj, '__dict__'):
        return simplejson.dumps(obj, default=encoders.as_object)

    return simplejson.dumps(obj)
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()