Skip to content

Commit dd73607

Browse files
committed
Make dateutil compulsory in article.py
This ensures correct dates in published articles
1 parent 8067c1b commit dd73607

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using the `--sandbox` switch.
2626
#### 1. Pre-Publication (article DOI, URL and number)
2727

2828
Run the [process.py](process.py) script using the provided metadata
29-
file. It requires Python 3 plus the [PyYAML](https://pyyaml.org/) and [Requests](https://requests.kennethreitz.org/) libraries.
29+
file. It requires Python 3 plus the libraries [PyYAML](https://pyyaml.org/), [Requests](https://requests.kennethreitz.org/), and [dateutil](https://dateutil.readthedocs.io/en/stable/).
3030

3131
First run on the sandbox server to check everything is OK:
3232

article.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Released under the BSD two-clauses licence
33

44
import yaml
5+
import dateutil.parser
56

67
class Contributor:
78
def __init__(self, role, name, orcid="", email="", affiliations=[]):
@@ -74,23 +75,12 @@ def __init__(self, url, doi):
7475

7576
class Date:
7677
def __init__(self, date):
77-
try:
78-
import dateutil.parser
79-
80-
date = dateutil.parser.parse(date)
81-
self.date = date
82-
self.year = date.year
83-
self.month = date.month
84-
self.day = date.day
85-
self.textual = self.date.strftime("%d %B %Y")
86-
except:
87-
import datetime
88-
now = datetime.datetime.now()
89-
self.date = now
90-
self.year = now.year
91-
self.month = now.month
92-
self.day = now.day
93-
self.textual = ""
78+
date = dateutil.parser.parse(date)
79+
self.date = date
80+
self.year = date.year
81+
self.month = date.month
82+
self.day = date.day
83+
self.textual = self.date.strftime("%d %B %Y")
9484

9585
def __str__(self):
9686
return self.textual

0 commit comments

Comments
 (0)