Merge branch 'reflow'
[wolnelektury.git] / src / wolnelektury / utils.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 import os
6 import pytz
7 from django.utils import timezone
8 from django.conf import settings
9
10 tz = pytz.timezone(settings.TIME_ZONE)
11
12
13 def localtime_to_utc(localtime):
14     return timezone.utc.normalize(
15         tz.localize(localtime)
16     )
17
18
19 def utc_for_js(dt):
20     return dt.strftime('%Y/%m/%d %H:%M:%S UTC')
21
22
23 def makedirs(path):
24     if not os.path.isdir(path):
25         os.makedirs(path)