Changed localize_date to formatdate
This commit is contained in:
parent
15fd8e7990
commit
2c9f2edd21
1 changed files with 11 additions and 14 deletions
|
|
@ -231,7 +231,7 @@ def get_datetime_str(datetime_obj):
|
|||
|
||||
return datetime_obj.strftime('%Y-%m-%d %H:%M:%S.%f')
|
||||
|
||||
def formatdate(string_date=None):
|
||||
def formatdate(string_date=None, format_string=None):
|
||||
"""
|
||||
Convers the given string date to :data:`user_format`
|
||||
User format specified in defaults
|
||||
|
|
@ -242,28 +242,25 @@ def formatdate(string_date=None):
|
|||
* mm-dd-yyyy
|
||||
* dd/mm/yyyy
|
||||
"""
|
||||
if string_date:
|
||||
string_date = getdate(string_date)
|
||||
date = getdate(string_date) if string_date else now_datetime().date()
|
||||
|
||||
if format_string:
|
||||
return babel.dates.format_date(date, format_string or "medium", locale=(frappe.local.lang or "").replace("-", "_"))
|
||||
else:
|
||||
string_date = now_datetime().date()
|
||||
if getattr(frappe.local, "user_format", None) is None:
|
||||
frappe.local.user_format = frappe.db.get_default("date_format")
|
||||
|
||||
if getattr(frappe.local, "user_format", None) is None:
|
||||
frappe.local.user_format = frappe.db.get_default("date_format")
|
||||
out = frappe.local.user_format
|
||||
|
||||
out = frappe.local.user_format
|
||||
|
||||
return out.replace("dd", string_date.strftime("%d"))\
|
||||
.replace("mm", string_date.strftime("%m"))\
|
||||
.replace("yyyy", string_date.strftime("%Y"))
|
||||
return out.replace("dd", date.strftime("%d"))\
|
||||
.replace("mm", date.strftime("%m"))\
|
||||
.replace("yyyy", date.strftime("%Y"))
|
||||
|
||||
def global_date_format(date):
|
||||
"""returns date as 1 January 2012"""
|
||||
formatted_date = getdate(date).strftime("%d %B %Y")
|
||||
return formatted_date.startswith("0") and formatted_date[1:] or formatted_date
|
||||
|
||||
def localize_date(date, format_string=None, locale=None):
|
||||
return babel.dates.format_date(date, format_string or "medium", locale=locale or (frappe.local.lang or "").replace("-", "_"))
|
||||
|
||||
def dict_to_str(args, sep='&'):
|
||||
"""
|
||||
Converts a dictionary to URL
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue