-
Notifications
You must be signed in to change notification settings - Fork 509
Fix datetime handling in Excel exports #6887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
apparently setting the default on XlsxWriter does not prevent the locale from overwriting it.. honestly I think the best solution is to force the format on our end, since there's no easy way to override that in the library |
|
also I've realized I have to handle date fields as well |
| registration_dict[key] = '' | ||
| continue | ||
| dt = datetime.fromisoformat(data[item.id].data).replace(tzinfo=tzinfo) | ||
| if ':' in item.data.get('date_format'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is the best way to determine if it's a date or a date time. unfortunately the time_format has been lost by this stage
fb7b9ef to
cf845f2
Compare
|
I think you're back to storing it as a string now... If I understand https://xlsxwriter.readthedocs.io/working_with_dates_and_time.html correctly, you need to pass a date/datetime object for the cell (so the library can then convert it to the weird format Excel uses), and also define a format via |
cf845f2 to
cda4adb
Compare
Got it. Fixed it now |
cda4adb to
89070a5
Compare
89070a5 to
7bb3056
Compare


Closes #6806
This PR fixes the
datetimeobject handling in Excel exports, following the recommendations in https://xlsxwriter.readthedocs.io/working_with_dates_and_time.htmlThe chosen format is
yyyy/mm/dd hh:mm:sswhich should be recognizable as a date in most locales.