Skip to content

Commit

Permalink
Move date_format to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
iaindillingham committed Dec 13, 2023
1 parent d90d9c9 commit b506081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 1 addition & 6 deletions analysis/render_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@ def b64encode(path):
return f"data:{mtype};base64, {encoded}"


def date_format(date):
"""Formats the given date as, for example, "1 January 2023"."""
return f"{date:%-d %B %Y}" # the - removes the leading zero, but not on Windows


# register template filters
ENVIRONMENT.filters["b64encode"] = b64encode
ENVIRONMENT.filters["date_format"] = date_format
ENVIRONMENT.filters["date_format"] = utils.date_format


def render_report(data):
Expand Down
5 changes: 5 additions & 0 deletions analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ def slugify(s):
# remove leading and trailing dashes and underscores
s = s.strip("-_")
return s.lower()


def date_format(date):
"""Formats the given date as, for example, "1 January 2023"."""
return f"{date:%-d %B %Y}" # the - removes the leading zero, but not on Windows

0 comments on commit b506081

Please sign in to comment.