Skip to content

Commit a6467c9

Browse files
ChasNelson1990gcushen
authored andcommitted
feat: support both 1 and 2 digit numeric months in BibLaTeX
See #41
1 parent f0ece65 commit a6467c9

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

academic/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,15 @@ def clean_bibtex_tags(s, normalize=False):
272272

273273

274274
def month2number(month):
275-
"""Convert BibTeX month to numeric"""
276-
month_abbr = month.strip()[:3].title()
277-
try:
278-
return str(list(calendar.month_abbr).index(month_abbr)).zfill(2)
279-
except ValueError:
280-
raise ValueError('Please update your BibTeX with valid months')
275+
"""Convert BibTeX or BibLateX month to numeric"""
276+
if len(month) <= 2: # Assume a 1 or 2 digit numeric month has been given.
277+
return month.zfill(2)
278+
else: # Assume a textual month has been given.
279+
month_abbr = month.strip()[:3].title()
280+
try:
281+
return str(list(calendar.month_abbr).index(month_abbr)).zfill(2)
282+
except ValueError:
283+
raise log.error('Please update the entry with a valid month.')
281284

282285

283286
def import_assets():

0 commit comments

Comments
 (0)