1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.conf import settings
6 from django import template
7 from django.utils import timezone
10 register = template.Library()
14 def date_to_utc(date, day_end=False):
15 """ Converts a datetime.date to UTC datetime.
17 The datetime represents the start (or end) of the given day in
18 the server's timezone.
21 date += datetime.timedelta(1)
23 localtime = datetime.datetime.combine(date, datetime.time(0, 0), timezone.get_current_timezone())
24 return timezone.localtime(localtime, timezone.utc)
29 return dt.strftime('%Y/%m/%d %H:%M:%S UTC')