Skip to content
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

Fix unknown timezone error for birthdate in patient listing #56

Merged
merged 2 commits into from
Oct 23, 2022

Conversation

ramonski
Copy link
Contributor

Description of the issue/feature this PR addresses

This PR fixes the following error that might occur for some timezones:

Traceback (innermost last):
  Module ZServer.ZPublisher.Publish, line 144, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZServer.ZPublisher.Publish, line 44, in call_object
  Module senaite.app.listing.view, line 236, in __call__
  Module senaite.app.listing.ajax, line 112, in handle_subpath
  Module senaite.core.decorators, line 22, in decorator
  Module senaite.app.listing.decorators, line 63, in wrapper
  Module senaite.app.listing.decorators, line 50, in wrapper
  Module senaite.app.listing.decorators, line 100, in wrapper
  Module senaite.app.listing.ajax, line 460, in ajax_folderitems
  Module senaite.app.listing.decorators, line 88, in wrapper
  Module senaite.app.listing.ajax, line 339, in get_folderitems
  Module senaite.app.listing.view, line 963, in folderitems
  Module senaite.patient.browser.patientfolder, line 200, in folderitem
  Module bika.lims.browser, line 46, in ulocalized_time
  Module senaite.core.api.dtime, line 349, in to_localized_time
  Module senaite.core.api.dtime, line 117, in to_DT
  Module DateTime.DateTime, line 443, in __init__
  Module DateTime.DateTime, line 769, in _parse_args
DateTimeError: Unknown time zone in date: 2018-02-10T00:00:00+00:14

The datetime object contains the following timezone information:

>>> birthdate
datetime.datetime(2018, 2, 10, 0, 0, tzinfo=<DstTzInfo 'Africa/Libreville' LMT+0:14:00 STD>)
>>> self.ulocalized_time(birthdate, long_format=0)
*** DateTimeError: Unknown time zone in date: 2018-02-10T00:00:00+00:14

Possible related issue:

zopefoundation/DateTime#31

Current behavior before PR

DateTimeError occurs for birthdates with timezone information stored

Desired behavior after PR is merged

Birthdate is returned as date object per default

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@ramonski
Copy link
Contributor Author

TODO: Check this thread for a better place to handle the timezone:
https://groups.google.com/g/django-users/c/rXalwEztfr0/m/VrcclsvfHeoJ

@xispa xispa merged commit 00f2b28 into master Oct 23, 2022
@xispa xispa deleted the fix-birthdate-datetime-error branch October 23, 2022 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants