Encode datetime.datetime.
190267
def _encode_datetime(name, value, dummy0, dummy1):
    """"""
    millis = _datetime_to_millis(value)
    return b"\x09" + name + _PACK_LONG(millis)
351862
def merge_datetime(date, time='', date_format='%d/%m/%Y', time_format='%H:%M'):
    """"""
    day = datetime.strptime(date, date_format)
    if time:
        time = datetime.strptime(time, time_format)
        time = datetime.time(time)
        day = datetime.date(day)
        day = datetime.combine(day, time)
    return day
543377
def convert_dict_to_datetime(obj_map):
    """"""
    converted_map = {}
    for key, value in obj_map.items():
        if isinstance(value, dict) and 'tzinfo' in value.keys():
            converted_map[key] = datetime.datetime(**value)
        elif isinstance(value, dict):
            converted_map[key] = convert_dict_to_datetime(value)
        elif isinstance(value, list):
            updated_list = []
            for internal_item in value:
                if isinstance(internal_item, dict):
                    updated_list.append(convert_dict_to_datetime(internal_item))
                else:
                    updated_list.append(internal_item)
            converted_map[key] = updated_list
        else:
            converted_map[key] = value
    return converted_map
732236
def _date_to_datetime(value):
  
  if not isinstance(value, datetime.date):
    raise TypeError('Cannot convert to datetime expected date value; '
                    'received %s' % value)
  return datetime.datetime(value.year, value.month, value.day)
347918
def _convert_datetime_str(response):
    '''
    
    '''
    if response:
        return dict([(k, '{0}'.format(v)) if isinstance(v, datetime.date) else (k, v) for k, v in six.iteritems(response)])
    return None
504326
def _datetime_to_utc(self, dt):
        """"""

        if not dt.tzinfo:
            dt = dt.replace(tzinfo=tz.gettz())
        return dt.astimezone(tz.gettz('UTC'))
1041036
def _encode_datetime_with_cftime(dates, units, calendar):
    
    cftime = _import_cftime()

    if np.issubdtype(dates.dtype, np.datetime64):
        # numpy's broken datetime conversion only works for us precision
        dates = dates.astype('M8[us]').astype(datetime)

    def encode_datetime(d):
        return np.nan if d is None else cftime.date2num(d, units, calendar)

    return np.vectorize(encode_datetime)(dates)
203629
def _convert_date_time_string(dt_string):
    '''
    
    '''
    dt_string = dt_string.split('.')[0]
    dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S')
    return dt_obj.strftime('%Y-%m-%d %H:%M:%S')
553026
def _serialize_datetime(value):
    """"""
    if not isinstance(value, (datetime, arrow.Arrow)):
        raise ValueError(u'The received object was not a datetime: '
                         u'{} {}'.format(type(value), value))
    return value.isoformat()
836252
def _encode_time(self, value):
        """"""

        if self._kp.version >= (4, 0):
            diff_seconds = int(
                (
                    self._datetime_to_utc(value) -
                    datetime(
                        year=1,
                        month=1,
                        day=1,
                        tzinfo=tz.gettz('UTC')
                    )
                ).total_seconds()
            )
            return base64.b64encode(
                struct.pack('<Q', diff_seconds)
            ).decode('utf-8')
        else:
            return self._datetime_to_utc(value).isoformat()
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
689169
def datetime(self):
        """"""
        return dt.datetime(
            self.year(), self.month(), self.day(),
            self.hour(), self.minute(), self.second(),
            int(self.millisecond() * 1e3))
493297
def datetime_to_time(date, time):
    """"""
    if (255 in date) or (255 in time):
        raise RuntimeError("specific date and time required")

    time_tuple = (
        date[0]+1900, date[1], date[2],
        time[0], time[1], time[2],
        0, 0, -1,
        )
    return _mktime(time_tuple)
543314
protected function encodeDateTime(DateTime $value = null) {
        return null === $value ? "" : $value->format(self::DATETIME_FORMAT);
    }
569167
def time_to_datetime(x):
    """"""
    if isinstance(x, time):
        return datetime.combine(date(1970, 1, 1), x)
    return x
957930
def _encode(cls, value):
        """"""

        value = json.dumps(value)
        return cls._ENC_RE.sub(lambda x: '%%%2x' % ord(x.group(0)), value)
881236
def encode_datetime(o):
    
    r = o.isoformat()
    if o.microsecond:
        r = r[:23] + r[26:]
    if r.endswith('+00:00'):
        r = r[:-6] + 'Z'
    return r