0001-utils-add-method-to-convert-datetime-to-UTC-and-to-x.patch
src/authentic2/utils.py | ||
---|---|---|
21 | 21 |
from django import forms |
22 | 22 |
from django.forms.util import ErrorList |
23 | 23 |
from django.forms.utils import to_current_timezone |
24 |
from django.utils import timezone |
|
24 | 25 |
from django.utils import html, http |
25 | 26 |
from django.utils.translation import ugettext as _ |
26 | 27 |
from django.shortcuts import resolve_url |
... | ... | |
616 | 617 |
else: |
617 | 618 |
messages.warning(request, _('No user to switch back to')) |
618 | 619 |
return continue_to_next_url(request) |
620 | ||
621 |
def datetime_to_utc(dt): |
|
622 |
if timezone.is_naive(dt): |
|
623 |
dt = timezone.make_aware(dt) |
|
624 |
return dt.astimezone(timezone.utc) |
|
625 | ||
626 |
def datetime_to_xs_datetime(dt): |
|
627 |
return datetime_to_utc(dt).isoformat().split('.')[0] + 'Z' |
|
619 |
- |