-
-
Notifications
You must be signed in to change notification settings - Fork 144
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 ValueError when displaying dates before 1900 (by datetimewidget) #2292
Conversation
Doctest for 11cba59 is failing:
A bit confused though: >>> from bika.lims import api
>>> from senaite.core.api import dtime
>>> from datetime import datetime
>>> from DateTime import DateTime
>>> portal = api.get_portal()
>>> ts = api.get_tool("translation_service")
>>> dt = "2022-12-14"
>>> ts.ulocalized_time(dt, long_format=True, context=portal, domain="senaite.core")
u'14/12/2022 01:00'
>>> dtime.to_localized_time(dt, long_format=True, context=portal)
u'14/12/2022 01:00'
>>> dt = datetime(2012,12,14)
>>> ts.ulocalized_time(dt, long_format=True, context=portal, domain="senaite.core")
u'14/12/2012 00:00'
>>> dtime.to_localized_time(dt, long_format=True, context=portal)
u'14/12/2012 01:00'
>>> dt = DateTime(2012,12,14)
>>> ts.ulocalized_time(dt, long_format=True, context=portal, domain="senaite.core")
u'14/12/2012 00:00'
>>> dtime.to_localized_time(dt, long_format=True, context=portal)
u'14/12/2012 00:00' |
Got it,
|
Description of the issue/feature this PR addresses
This Pull Request makes the date time widget to not fail when displaying dates before year 1900 (see https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior)
Current behavior before PR
Desired behavior after PR is merged
Dates before 1900 are displayed (in iso-like format) without error
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.