mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 22:04:48 +03:00
convert datetimes to the appropriate timezone on their way out
This commit is contained in:
parent
a825098440
commit
48e75379c1
|
@ -941,6 +941,11 @@ class DateTimeField(Field):
|
|||
self.fail('invalid', format=humanized_format)
|
||||
|
||||
def to_representation(self, value):
|
||||
if timezone.is_aware(value):
|
||||
# convert the datetime to the timezone the user is expecting
|
||||
tz = getattr(timezone._active, "value", self.default_timezone)
|
||||
value = timezone.localtime(value, tz)
|
||||
|
||||
if self.format is None:
|
||||
return value
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user