Skip to content

Commit

Permalink
timing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Morris committed Oct 5, 2024
1 parent e6a75a9 commit 90b6410
Show file tree
Hide file tree
Showing 7 changed files with 9,422 additions and 3,453 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
All of the poems in here are good, or interesting. There are currently 8,982 poems in 43 (3.575) languages by 592 (254.896) authors from 82 (13.732) countries.
All of the poems in here are good, or interesting. There are currently 8,982 poems in 44 (3.578) languages by 592 (254.896) authors from 82 (13.732) countries.

(The quantites in the parentheses are the effective counts, based on the entropy of the distribution over the poems.)
10 changes: 9 additions & 1 deletion poems/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __post_init__(self):
self.liturgy = get_liturgy(self.timestamp)
self.holiday = get_holiday(self.timestamp)
self.month_epoch = get_month_epoch(self.timestamp)
self.year_epoch = get_year_epoch(self.timestamp)
self.year_day = self.datetime.timetuple().tm_yday
self.weekday = WEEKDAYS[self.datetime.weekday()]

Expand Down Expand Up @@ -64,11 +65,13 @@ def to_dict(self):
"liturgy": self.liturgy,
"holiday": self.holiday,
"year": self.year,
"year_epoch": self.year_epoch,
"month": self.month,
"month_epoch": self.month_epoch,
"day": self.day,
"year_day": self.year_day,
"weekday": self.weekday,
"month_epoch": self.month_epoch}
}


def get_utc_datetime(when=None):
Expand Down Expand Up @@ -229,6 +232,11 @@ def get_advent_sunday_year_day(year):
christmas_year_day = datetime(year,12,25).timetuple().tm_yday
return christmas_year_day - (22 + datetime(year,12,25).weekday())

def get_year_epoch(t=None):
month = get_utc_datetime(t).month
if month < 5: return "early"
if month < 9: return "middle"
return "late"

def get_month_epoch(t=None):
dt = get_utc_datetime(t)
Expand Down
Loading

0 comments on commit 90b6410

Please sign in to comment.