Browse Source

don't break plugins, raise a warning instead

micha 7 years ago
parent
commit
c2f09a3603
1 changed files with 11 additions and 1 deletions
  1. 11 1
      flaskbb/utils/helpers.py

+ 11 - 1
flaskbb/utils/helpers.py

@@ -12,6 +12,7 @@ import ast
 import itertools
 import itertools
 import logging
 import logging
 import operator
 import operator
+import warnings
 import os
 import os
 import re
 import re
 import time
 import time
@@ -441,12 +442,21 @@ def format_datetime(datetime):
     return _format_html_time_tag(datetime, 'date-and-time')
     return _format_html_time_tag(datetime, 'date-and-time')
 
 
 
 
-def format_date(datetime):
+def format_date(datetime, format=None):
     """Format the datetime for usage in templates, keeping only the date.
     """Format the datetime for usage in templates, keeping only the date.
 
 
     :param value: The datetime object that should be formatted
     :param value: The datetime object that should be formatted
     :rtype: Markup
     :rtype: Markup
     """
     """
+    if format:
+        warnings.warn(
+            'This API has been deprecated due to i18n concerns.  Please use  '
+            'Jinja filters format_datetime and format_date without arguments '
+            'to format complete and date-only timestamps respectively.',
+            DeprecationWarning
+        )
+        if '%H' in format:
+            return format_datetime(datetime)
     return _format_html_time_tag(datetime, 'date-only')
     return _format_html_time_tag(datetime, 'date-only')