]> khamidou — GitHub mirrors - cookie-cutter.git/commitdiff
Add utils
authorKarim Hamidou <khamidou@gmail.com>
Sun, 17 Oct 2021 16:21:55 +0000 (09:21 -0700)
committerKarim Hamidou <khamidou@gmail.com>
Sun, 17 Oct 2021 16:21:55 +0000 (09:21 -0700)
requirements.txt
web/util.py [new file with mode: 0644]

index 001d3d3ada182da17ffd89c2576f4e865cee8882..e7d77c8e672148a4b1e4309e1e7da0224bd82f46 100644 (file)
@@ -2,5 +2,6 @@ Django==3.2.8
 dj-database-url==0.5.0
 django-environ==0.7.0
 gunicorn==20.1.0
+pytz==2021.3
 psycopg2==2.9.1
 whitenoise==5.3.0
diff --git a/web/util.py b/web/util.py
new file mode 100644 (file)
index 0000000..03839bb
--- /dev/null
@@ -0,0 +1,14 @@
+import datetime
+import pytz
+import random
+import string
+
+
+r = random.SystemRandom()
+
+def random_string(length=127):
+    return ''.join(r.choices(string.ascii_letters + string.digits, k=length))
+
+
+def utc_now():
+    return pytz.utc.localize(datetime.datetime.utcnow())