Skip to content

Commit

Permalink
refactor: use fromisoformat instead of strptime
Browse files Browse the repository at this point in the history
  • Loading branch information
null8626 committed Oct 19, 2024
1 parent e457ef1 commit 58b7a19
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python_weather/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, json: dict, unit: _Unit, locale: Locale):
self.chances_of_thunder = int(json['chanceofthunder'])
self.chances_of_windy = int(json['chanceofwindy'])
self.cloud_cover = int(json['cloudcover'])
self.time = time() if len(t) < 3 else datetime.strptime(t, '%H%M').time()
self.time = time() if len(t) < 3 else time.fromisoformat(t)
self.dew_point = int(json[f'DewPoint{unit.temperature}'])
self.heat_index = HeatIndex._new(
celcius_index,
Expand Down Expand Up @@ -201,7 +201,7 @@ def __init__(self, json: dict, unit: _Unit, locale: Locale):
self.moonset = __class__.__parse_time(astronomy['moonset'])
self.sunrise = __class__.__parse_time(astronomy['sunrise'])
self.sunset = __class__.__parse_time(astronomy['sunset'])
self.date = datetime.strptime(json['date'], '%Y-%m-%d').date()
self.date = date.fromisoformat(json['date'])
self.sunlight = float(json['sunHour'])
self.lowest_temperature = int(json[f'mintemp{unit.temperature}'])
self.highest_temperature = int(json[f'maxtemp{unit.temperature}'])
Expand Down

0 comments on commit 58b7a19

Please sign in to comment.