+def fallback_humanize(date, fallback_format=None, use_fallback=False):
+ """
+ Format date with arrow and a fallback format
+ """
+ # Convert to local timezone
+ date = arrow.get(date).to('local')
+ # Set default fallback format
+ if not fallback_format:
+ fallback_format = '%Y/%m/%d %H:%M:%S'
+ # Determine using fallback format or not by a variable
+ if use_fallback:
+ return date.datetime.strftime(fallback_format)
+ try:
+ # Use Arrow's humanize function
+ lang, encode = locale.getdefaultlocale()
+ clock = date.humanize(locale=lang)
+ except:
+ # Notice at the 1st time only
+ if not dg['humanize_unsupported']:
+ dg['humanize_unsupported'] = True
+ printNicely(
+ light_magenta('Humanized date display method does not support your $LC_ALL.'))
+ # Fallback when LC_ALL is not supported
+ clock = date.datetime.strftime(fallback_format)
+ return clock
+
+