Skip to content

Commit

Permalink
Merge branch 'vmatt-latest' into data_import_delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
vmatt committed Apr 29, 2024
2 parents 3774c74 + bf8849b commit 98bd595
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frappe/core/doctype/data_import/data_import.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
}
14 changes: 13 additions & 1 deletion frappe/core/doctype/data_import_log/data_import_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-03-23 16:02:17.334396",
"modified": "2024-04-16 17:32:34.363704",
"modified_by": "Administrator",
"module": "Core",
"name": "Data Import Log",
Expand All @@ -77,6 +77,18 @@
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "SSport Role",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
Expand Down
36 changes: 36 additions & 0 deletions frappe/tests/test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import datetime

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.utils.data import guess_date_format

test_date_obj = datetime.datetime.now()
test_datetime = test_date_obj.strftime("%Y-%m-%d %H:%M:%S.%f")
test_date_formats = {
"%Y-%m-%d": test_date_obj.strftime("%Y-%m-%d"),
"%d-%m-%Y": test_date_obj.strftime("%d-%m-%Y"),
"%d/%m/%Y": test_date_obj.strftime("%d/%m/%Y"),
"%d.%m.%Y": test_date_obj.strftime("%d.%m.%Y"),
"%m/%d/%Y": test_date_obj.strftime("%m/%d/%Y"),
"%m-%d-%Y": test_date_obj.strftime("%m-%d-%Y"),
"%Y.%m.%d.": test_date_obj.strftime("%Y.%m.%d."),
}
test_time_formats = {
"%H:%M:%S": test_date_obj.strftime("%H:%M:%S"),
"%H:%M": test_date_obj.strftime("%H:%M"),
}


class TestData(FrappeTestCase):
"""Tests date, time and datetime formatters and some associated
utility functions. These rely on the system-wide date and time
formats.
"""

def test_guess_format(self):
# Test formatdate with various default date formats set
for valid_format, date_str in test_date_formats.items():
frappe.db.set_default("date_format", valid_format)
self.assertEqual(guess_date_format(date_str), valid_format)
1 change: 1 addition & 0 deletions frappe/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,7 @@ def guess_date_format(date_string: str) -> str:
r"%y.%m.%d",
r"%d %b %Y",
r"%d %B %Y",
r"%Y.%m.%d.",
]

TIME_FORMATS = [
Expand Down

0 comments on commit 98bd595

Please sign in to comment.