

def _db_set_value(self, v, p, value):
    if (not isinstance(value, datetime.datetime)):
        raise TypeError(('DatetimeProperty %s can only be set to datetime values; received %r' % (self._name, value)))
    if (value.tzinfo is not None):
        raise NotImplementedError(('DatetimeProperty %s can only support UTC. Please derive a new Property to support alternative timezones.' % self._name))
    dt = (value - _EPOCH)
    ival = (dt.microseconds + (1000000 * (dt.seconds + ((24 * 3600) * dt.days))))
    v.set_int64value(ival)
    p.set_meaning(entity_pb.Property.GD_WHEN)

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py DateTimeProperty._db_set_value/original