Add timezone support and an authenticated view
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
import datetime
|
||||
import settings
|
||||
|
||||
import pytz
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
# need to translate to a non-naive timezone, even if timezone == settings.TIME_ZONE, so we can compare two dates
|
||||
def to_user_timezone(date, profile):
|
||||
@ -17,7 +20,12 @@ def to_system_timezone(date, profile):
|
||||
)
|
||||
|
||||
|
||||
def now_timezone():
|
||||
def now_user_timezone(profile):
|
||||
timezone.activate(pytz.timezone(profile.timezone))
|
||||
return timezone.localtime(timezone.now())
|
||||
|
||||
|
||||
def now_system_timezone():
|
||||
return (
|
||||
datetime.datetime.now()
|
||||
.replace(tzinfo=pytz.timezone(settings.TIME_ZONE))
|
||||
|
||||
Reference in New Issue
Block a user