Skip to content

Commit

Permalink
Merge pull request #51 from blablatdinov/34-render-dates
Browse files Browse the repository at this point in the history
#34 render dates
  • Loading branch information
yegor256 authored Jul 17, 2024
2 parents 69d4fc3 + 53ef7c9 commit 8a48af8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import datetime
import sys
from pathlib import Path
from typing import TypedDict
from typing import Literal, TypeAlias, TypedDict

import yaml

DateAsStrT: TypeAlias = str
RawDateT: TypeAlias = DateAsStrT | Literal["closed"]


class ConfInfoDict(TypedDict):

Expand Down Expand Up @@ -55,6 +59,19 @@ def build_name(conf_name: str, conf_info: ConfInfoDict) -> str:
return "[{0}'{1}](<{2}>)".format(conf_name, year_last_two_digit, conf_info["url"])


def render_date(raw_date: RawDateT):
"""Render date.
>>> render_date("2020-01-01")
'20-Jan'
>>> render_date("closed")
'closed'
"""
if raw_date == "closed":
return "closed"
return datetime.datetime.strptime(raw_date, "%Y-%m-%d").strftime("%y-%b")


def build_row(conf_name: str, conf_info: list[dict], markdown_table_row_template: str):
conf_info_dict = {}
for row in conf_info:
Expand All @@ -69,7 +86,7 @@ def build_row(conf_name: str, conf_info: list[dict], markdown_table_row_template
short=conf_info_dict["short"],
full=conf_info_dict["full"],
format=conf_info_dict["format"],
cfp=conf_info_dict["cfp"],
cfp=render_date(conf_info_dict["cfp"]),
country=conf_info_dict["country"],
)

Expand Down
2 changes: 1 addition & 1 deletion fixtures/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- events -->
| name | publisher | rank | scope | short | full | format | cfp | country |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [ABC'99](<https://conf.researchr.org/series/abc>) | IEEE | [C](<https://portal.core.edu.au/conf-ranks/2099>) | SE | 2 | 10 | 1C | 2099-12-31 | Antarctica |
| [ABC'99](<https://conf.researchr.org/series/abc>) | IEEE | [C](<https://portal.core.edu.au/conf-ranks/2099>) | SE | 2 | 10 | 1C | 99-Dec | Antarctica |

<!-- events -->
Explanations for abbreviations.
2 changes: 1 addition & 1 deletion fixtures/simple/expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- events -->
| name | publisher | rank | scope | short | full | format | cfp | country |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [ABC'99](<https://conf.researchr.org/series/abc>) | IEEE | [C](<https://portal.core.edu.au/conf-ranks/2099>) | SE | 2 | 10 | 1C | 2099-12-31 | Antarctica |
| [ABC'99](<https://conf.researchr.org/series/abc>) | IEEE | [C](<https://portal.core.edu.au/conf-ranks/2099>) | SE | 2 | 10 | 1C | 99-Dec | Antarctica |

<!-- events -->
Explanations for abbreviations.

0 comments on commit 8a48af8

Please sign in to comment.