Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(biblatex): support 1-/2-digit numeric months #41

Merged
merged 2 commits into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions academic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,15 @@ def clean_bibtex_tags(s, normalize=False):


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


def import_assets():
Expand Down