Add date format configurability to date format function (#5037)

This commit is contained in:
Raghavendra Kamath 2018-02-20 17:25:33 +05:30 committed by Rushabh Mehta
parent aa5f9516da
commit 08a6727fb8

View file

@ -254,10 +254,10 @@ def format_datetime(datetime_string, format_string=None):
formatted_datetime = datetime.strftime('%Y-%m-%d %H:%M:%S')
return formatted_datetime
def global_date_format(date):
def global_date_format(date, format="long"):
"""returns localized date in the form of January 1, 2012"""
date = getdate(date)
formatted_date = babel.dates.format_date(date, locale=(frappe.local.lang or "en").replace("-", "_"), format="long")
formatted_date = babel.dates.format_date(date, locale=(frappe.local.lang or "en").replace("-", "_"), format=format)
return formatted_date
def has_common(l1, l2):