diff sat/tools/common/date_utils.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 3e4e78de9cca
children 3ba53b1cd1e6
line wrap: on
line diff
--- a/sat/tools/common/date_utils.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/tools/common/date_utils.py	Wed Jun 27 20:14:46 2018 +0200
@@ -36,7 +36,15 @@
     return calendar.timegm(dateutil_parser.parse(unicode(value)).utctimetuple())
 
 
-def date_fmt(timestamp, fmt='short', date_only=False, auto_limit=7, auto_old_fmt='short', auto_new_fmt='relative', locale_str=C.DEFAULT_LOCALE):
+def date_fmt(
+    timestamp,
+    fmt="short",
+    date_only=False,
+    auto_limit=7,
+    auto_old_fmt="short",
+    auto_new_fmt="relative",
+    locale_str=C.DEFAULT_LOCALE,
+):
     """format date according to locale
 
     @param timestamp(basestring, int): unix time
@@ -63,9 +71,9 @@
         than limit
 
     """
-    if fmt == 'auto_day':
-        fmt, auto_limit, auto_old_fmt, auto_new_fmt = 'auto', 0, 'short', 'HH:mm'
-    if fmt == 'auto':
+    if fmt == "auto_day":
+        fmt, auto_limit, auto_old_fmt, auto_new_fmt = "auto", 0, "short", "HH:mm"
+    if fmt == "auto":
         if auto_limit == 0:
             today = time.mktime(datetime.date.today().timetuple())
             if int(timestamp) < today:
@@ -79,15 +87,17 @@
             else:
                 fmt = auto_new_fmt
 
-    if fmt == 'relative':
+    if fmt == "relative":
         delta = int(timestamp) - time.time()
-        return dates.format_timedelta(delta, granularity="minute", add_direction=True, locale=locale_str)
-    elif fmt in ('short', 'long'):
+        return dates.format_timedelta(
+            delta, granularity="minute", add_direction=True, locale=locale_str
+        )
+    elif fmt in ("short", "long"):
         formatter = dates.format_date if date_only else dates.format_datetime
         return formatter(int(timestamp), format=fmt, locale=locale_str)
-    elif fmt == 'iso':
+    elif fmt == "iso":
         if date_only:
-            fmt = 'yyyy-MM-dd'
+            fmt = "yyyy-MM-dd"
         else:
             fmt = "yyyy-MM-ddTHH:mm:ss'Z'"
         return dates.format_datetime(int(timestamp), format=fmt)