File tree Expand file tree Collapse file tree
wikidataintegrator/wdi_helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,7 +327,19 @@ def crossref_api_to_publication(ext_id, id_type="doi"):
327327
328328 p .title = r ['title' ][0 ]
329329 p .published_in_issn = r .get ('ISSN' , [None ])[0 ]
330- p .publication_date = datetime .datetime .fromtimestamp (int (r ['created' ]['timestamp' ]) / 1000 )
330+
331+ # p.publication_date = datetime.datetime.fromtimestamp(int(r['created']['timestamp']) / 1000)
332+ year = r ['issued' ]['date-parts' ][0 ][0 ]
333+ if len (r ['issued' ]['date-parts' ][0 ]) == 1 :
334+ p .publication_date = datetime .datetime (year = year )
335+ if len (r ['issued' ]['date-parts' ][0 ]) == 2 :
336+ month = r ['issued' ]['date-parts' ][0 ][1 ]
337+ p .publication_date = datetime .datetime (year = year , month = month )
338+ if len (r ['issued' ]['date-parts' ][0 ]) == 3 :
339+ day = r ['issued' ]['date-parts' ][0 ][2 ]
340+ month = r ['issued' ]['date-parts' ][0 ][1 ]
341+ p .publication_date = datetime .datetime (year = year , month = month , day = day )
342+
331343 p .issue = r .get ('issue' )
332344 p .volume = r .get ('volume' )
333345 p .pages = r .get ('page' )
You can’t perform that action at this time.
0 commit comments