Closed PXke closed 3 years ago
@PXke This is in fact a general Python issue with the datetime library. There exists workarounds for this in the datetime library in Invenio: https://github.com/inveniosoftware/invenio/blob/master/modules/miscutil/lib/dateutils.py#L69
To fix this, we can change the import in bfe_meta.py
to use invenio.dateutils
:
https://github.com/inveniosoftware/invenio/blob/master/modules/bibformat/lib/elements/bfe_meta.py#L28
That would be really cool :) !
Setting in triage, as this can be a discussion we can have if we should go over and amend this where needed.
up.
@jalavik @PXke what is the desired milestone? Is there a related PR?
We have no PR for it. And no desired milestone for it. Even if like always earlier is better.
I upped it mainly because of the comment of @jalavik about that this can be a discussion.
We have no PR for it. And no desired milestone for it. Even if like always earlier is better.
@PXke If your time permits, perhaps you could take care of this? Our own strftime
is a drop-in replacement for the default system function, so it should be relatively straightforward to fix this.
E.g. here is good example from BibAuthorID:
$ git grep strftime modules/bibauthorid/lib/
modules/bibauthorid/lib/bibauthorid_webapi.py:from invenio.dateutils import strftime
modules/bibauthorid/lib/bibauthorid_webapi.py: strtimestamp = strftime("%Y-%m-%d %H:%M:%S", gmtime())
One needs to amend bfe_meta.py
and friends in a similar way...
Yeah, basically one has to think about where to apply it. The obvious target is to address places like formatting (display/exporting) where we work with records which may have bibliographic metadata dates prior to 1900. As you can imagine, it is not needed to do anything in modules where it deals with dates that are not bibliographic metadata.
@jalavik @egabancho we should then check JSONAlchemy fields definition for __import__('datetime')
.
@PXke Would you like to have a go at this?
@tiborsimko it is a bit complicated, it will depend of a lot of things and @audub .
OK. Let's keep you as the "driver" of this issue, until a new assignee comes, OK?
Yes no problem. If I have time I will do it :wink:
@PXke Note that some work is already done in #2728
\ User details No client information available
\ Traceback details
Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/invenio/bibformat_engine.py", line 717, in eval_format_element output_text = function(*_params) File "/usr/lib64/python2.7/site-packages/invenio/bibformat_elements/bfe_meta.py", line 138, in format_element parsed_date = parse_date_for_googlescholar(out[idx]) File "/usr/lib64/python2.7/site-packages/invenio/bibformat_elements/bfe_meta.py", line 232, in parse_date_forgooglescholar return datetime((parsed_datetime[0:6])).strftime('%Y/%m/%d') ValueError: year=1488 is before 1900; the datetime strftime() methods require year >= 1900