Skip to content

Commit

Permalink
Merge pull request #71 from wfmexpert/fix_43662
Browse files Browse the repository at this point in the history
43662 fix date field
  • Loading branch information
emmanuilyan committed Mar 26, 2024
2 parents 9197ae3 + 37bb93e commit fb714c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='verme-logs',
version='1.28.41',
version='1.28.42',
packages=find_packages(),
include_package_data=True,
license='BSD License', # example license
Expand Down
5 changes: 4 additions & 1 deletion xlsexport/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from django.db.models import Q
from openpyxl import load_workbook

HARDCODE_DATE_FORMAT = ('%d-%m-%Y', '%d.%m.%Y', '%d/%m/%Y')


class CustomException(Exception):
pass
Expand Down Expand Up @@ -330,7 +332,8 @@ def get_formatted_field(value, format, file_format):
try:
formatted_value = datetime.datetime.strptime(value, format)
except TypeError:
if isinstance(value, datetime.datetime) and format == '%Y-%m-%d':
# Для случаев, когда у модели поле вида Date, а не DateTime.
if isinstance(value, datetime.datetime) and format in HARDCODE_DATE_FORMAT:
formatted_value = value.date()
else:
formatted_value = get_cell_date(value, file_format)
Expand Down

0 comments on commit fb714c6

Please sign in to comment.