Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ghadialhajj committed Jan 26, 2024
2 parents 49fda5e + cb4ac1b commit 6445378
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
33 changes: 31 additions & 2 deletions climate_health/time_period/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
class TimePeriod:
pass
def __init__(self):
pass
@classmethod
def from_string(cls, time_string):
year, month = time_string.split('-')
return Month(year=year, month=month)


class Month:
pass
def __init__(self, year: int|str, month: int|str) -> None:
"""
:param year:
:param month: Starting from 1
"""
self.year = int(year)
self.month = int(month)


def __str__(self) -> str:
dict_month = {
1: 'January',
2: 'February',
3: 'March',
4: 'April',
5: 'May',
6: 'June',
7: 'July',
8: 'August',
9: 'September',
10: 'October',
11: 'November',
12: 'December',
}
return f'{dict_month[self.month]} {self.year}'
3 changes: 1 addition & 2 deletions tests/time_period/test_data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from climate_health.time_period import TimePeriod, Month


@pytest.mark.xfail
def test_time_period():
month = TimePeriod.from_str('2013-01')
month = TimePeriod.from_string('2013-01')
assert str(month) == 'January 2013'

0 comments on commit 6445378

Please sign in to comment.