Skip to content

Commit

Permalink
Fix timezone when convert timestamp to datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred82santa committed Nov 10, 2016
1 parent 980ba09 commit fefcc57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.rst
Expand Up @@ -85,6 +85,11 @@ Features
Changelog
---------

Version 0.9.2
-------------

- Fix timezone when convert timestamp to datetime.

Version 0.9.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion dirty_models/__init__.py
Expand Up @@ -7,4 +7,4 @@
from .models import *
from .fields import *

__version__ = '0.9.1'
__version__ = '0.9.2'
4 changes: 2 additions & 2 deletions dirty_models/fields.py
Expand Up @@ -416,7 +416,7 @@ def convert_value(self, value):
elif isinstance(value, dict):
return time(**value)
elif isinstance(value, int):
return self.convert_value(datetime.fromtimestamp(value))
return self.convert_value(datetime.fromtimestamp(value, tz=self.default_timezone))
elif isinstance(value, str):
try:
if not self.parse_format:
Expand Down Expand Up @@ -547,7 +547,7 @@ def convert_value(self, value):
elif isinstance(value, dict):
return datetime(**value)
elif isinstance(value, int):
return datetime.fromtimestamp(value)
return datetime.fromtimestamp(value, tz=self.default_timezone)
elif isinstance(value, str):
try:
if not self.parse_format:
Expand Down

0 comments on commit fefcc57

Please sign in to comment.