def _dt_setter(self, fieldtoset, value, **kwargs): """Always set the date in UTC, saving the timezone in another field. But since the timezone value isn't known at the time of saving the form, we have to save it timezone-naive first and let timezone_handler convert it to the target zone afterwards. """ # Note: The name of the first parameter shouldn't be field, because # it's already in kwargs in some case. if not isinstance(value, DateTime): value = DT(value) # This way, we set DateTime timezoneNaive value = DateTime( "%04d-%02d-%02dT%02d:%02d:%02d" % ( value.year(), value.month(), value.day(), value.hour(), value.minute(), int(value.second()), # No microseconds ) ) self.getField(fieldtoset).set(self, value, **kwargs)
def _dt_setter(self, fieldtoset, value, **kwargs): """Always set the date in UTC, saving the timezone in another field. But since the timezone value isn't known at the time of saving the form, we have to save it timezone-naive first and let timezone_handler convert it to the target zone afterwards. """ # Note: The name of the first parameter shouldn't be field, because # it's already in kwargs in some case. if not isinstance(value, DateTime): value = DT(value) # This way, we set DateTime timezoneNaive value = DateTime('%04d-%02d-%02dT%02d:%02d:%02d' % ( value.year(), value.month(), value.day(), value.hour(), value.minute(), int(value.second()) # No microseconds )) self.getField(fieldtoset).set(self, value, **kwargs)