Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made created_time when saving a FacebookLike timezone aware. #452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions django_facebook/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# using compatible_datetime instead of datetime only
# not to override the original datetime package
from django.utils import timezone as compatible_datetime
from django.utils.timezone import utc
except ImportError:
from datetime import datetime as compatible_datetime
from datetime import datetime
Expand Down Expand Up @@ -626,7 +627,11 @@ def get_class_from_string(path, default=None):


def parse_like_datetime(dt):
return datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S+0000")
try:
result = datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S+0000")
return result.replace(tzinfo=utc)
except AttributeError:
return result


def get_default_mapping():
Expand Down Expand Up @@ -672,7 +677,7 @@ def get_migration_data():
'''
Support for Django custom user models
See this blog post for inspiration

http://kevindias.com/writing/django-custom-user-models-south-and-reusable-apps/
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/migrations/0005_auto__chg_field_sitepermission_user__del_unique_sitepermission_user.py
'''
Expand Down