aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-11-21 11:40:10 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-11-21 11:40:16 -0800
commit008366697aba8046fd33ae1f3707972d87c9a342 (patch)
treefa0872d53cd8a2c3d75f1a27134b268254c3c65a /python/fatcat_tools
parent8232478d124d44b3988817a09d256c84157ebc4d (diff)
downloadfatcat-008366697aba8046fd33ae1f3707972d87c9a342.tar.gz
fatcat-008366697aba8046fd33ae1f3707972d87c9a342.zip
use isoformat() to format dates
This shouldn't change behavior; it's just more consistent.
Diffstat (limited to 'python/fatcat_tools')
-rw-r--r--python/fatcat_tools/harvest/doi_registrars.py4
-rw-r--r--python/fatcat_tools/harvest/oaipmh.py4
-rw-r--r--python/fatcat_tools/transforms.py3
3 files changed, 6 insertions, 5 deletions
diff --git a/python/fatcat_tools/harvest/doi_registrars.py b/python/fatcat_tools/harvest/doi_registrars.py
index 9518a96d..0296a9d9 100644
--- a/python/fatcat_tools/harvest/doi_registrars.py
+++ b/python/fatcat_tools/harvest/doi_registrars.py
@@ -10,7 +10,7 @@ import datetime
from pykafka import KafkaClient
from fatcat_tools.workers import most_recent_message
-from .harvest_common import HarvestState, DATE_FMT
+from .harvest_common import HarvestState
# Skip pylint due to:
# AttributeError: 'NoneType' object has no attribute 'scope'
@@ -90,7 +90,7 @@ class HarvestCrossrefWorker:
produce_topic = self.kafka.topics[self.produce_topic]
- date_str = date.strftime(DATE_FMT)
+ date_str = date.isoformat()
params = self.params(date_str)
headers = {
'User-Agent': 'fatcat_tools/0.1.0 (https://fatcat.wiki; mailto:{}) python-requests'.format(self.contact_email),
diff --git a/python/fatcat_tools/harvest/oaipmh.py b/python/fatcat_tools/harvest/oaipmh.py
index 4485a59f..1f6c54b6 100644
--- a/python/fatcat_tools/harvest/oaipmh.py
+++ b/python/fatcat_tools/harvest/oaipmh.py
@@ -53,7 +53,7 @@ from pykafka import KafkaClient
import sickle
from fatcat_tools.workers import most_recent_message
-from .harvest_common import HarvestState, DATE_FMT
+from .harvest_common import HarvestState
class HarvestOaiPmhWorker:
@@ -83,7 +83,7 @@ class HarvestOaiPmhWorker:
def fetch_date(self, date):
api = sickle.Sickle(self.endpoint_url)
- date_str = date.strftime(DATE_FMT)
+ date_str = date.isoformat()
produce_topic = self.kafka.topics[self.produce_topic]
# this dict kwargs hack is to work around 'from' as a reserved python keyword
# recommended by sickle docs
diff --git a/python/fatcat_tools/transforms.py b/python/fatcat_tools/transforms.py
index 147acd7c..87facd57 100644
--- a/python/fatcat_tools/transforms.py
+++ b/python/fatcat_tools/transforms.py
@@ -46,7 +46,8 @@ def release_to_elasticsearch(release):
)
if release.release_date:
- t['release_date'] = release.release_date.strftime('%F')
+ # .isoformat() results in, eg, '2010-10-22' (YYYY-MM-DD)
+ t['release_date'] = release.release_date.isoformat()
container = release.container
container_is_kept = False