From 84c50c9878ab051ffd4a5fce20e8f544bbd032aa Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Fri, 21 Oct 2022 11:25:03 -0500 Subject: [PATCH] Simplify date conversions Also do a sneaky update to switch from dict() to list() Change-Id: I71b65b82e8609fc4b3b48ef58acdf434ce69fe5c --- openstack_election/cmds/setup_election_config.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/openstack_election/cmds/setup_election_config.py b/openstack_election/cmds/setup_election_config.py index 0572638d..b0763699 100755 --- a/openstack_election/cmds/setup_election_config.py +++ b/openstack_election/cmds/setup_election_config.py @@ -102,9 +102,7 @@ def select_release_end_date(release_name, release_schedule): event = '%s-final' % (release_name[0:1]) for week in release_schedule.get('cycle', []): if event in week.get('x-project', []): - date = datetime.datetime.strptime( - week['end'], - "%Y-%m-%d").replace(tzinfo=pytz.UTC) + date = valid_date(week['end']) return date @@ -157,10 +155,8 @@ def main(): schedule = utils.get_schedule_data(names[idx+3]) event = '%s-rc1' % (names[idx+3][0:1]) for week in schedule.get('cycle', []): - if event in week.get('x-project', {}): - timeframe_start = datetime.datetime.strptime(week['end'], - "%Y-%m-%d") - timeframe_start = timeframe_start.replace(tzinfo=pytz.UTC) + if event in week.get('x-project', []): + timeframe_start = valid_date(week['end']) print('Setting %s Election\n%s is at: %s' % (args.type, params['milestone'],