Skip to content

Commit eab2ba5

Browse files
authored
Merge pull request #419 from wordpress-mobile/fix-milestone-dst-bug
Fix milestone due date bug when crossing DST boundaries
2 parents 4447e1e + 69642ba commit eab2ba5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _None_
1515
### Bug Fixes
1616

1717
- Improve resilience of the `ios_lint_localizations` action to support UTF16 files, and to warn and skip files in XML format when trying to detect duplicate keys on `.strings` files. [#418]
18+
- Work around GitHub API bug when creating a new milestone, where their interpretation of the milestone's due date sent during API call is incorrect when we cross DST change dates — leading to milestones created after Oct 30 having due dates set on Sunday instead of Monday. [#419]
1819

1920
### Internal Changes
2021

lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,25 @@ def self.create_milestone(repository, newmilestone_number, newmilestone_duedate,
8787
days_until_submission = need_submission ? (number_of_days_from_code_freeze_to_release - 3) : newmilestone_duration
8888
submission_date = newmilestone_duedate.to_datetime.next_day(days_until_submission)
8989
release_date = newmilestone_duedate.to_datetime.next_day(number_of_days_from_code_freeze_to_release)
90-
comment = "Code freeze: #{newmilestone_duedate.to_datetime.strftime('%B %d, %Y')} App Store submission: #{submission_date.strftime('%B %d, %Y')} Release: #{release_date.strftime('%B %d, %Y')}"
90+
comment = <<~MILESTONE_DESCRIPTION
91+
Code freeze: #{newmilestone_duedate.to_datetime.strftime('%B %d, %Y')}
92+
App Store submission: #{submission_date.strftime('%B %d, %Y')}
93+
Release: #{release_date.strftime('%B %d, %Y')}
94+
MILESTONE_DESCRIPTION
9195

9296
options = {}
93-
options[:due_on] = newmilestone_duedate
97+
# == Workaround for GitHub API bug ==
98+
#
99+
# It seems that whatever date we send to the API, GitHub will 'floor' it to the date that seems to be at
100+
# 00:00 PST/PDT and then discard the time component of the date we sent.
101+
# This means that, when we cross the November DST change date, where the due date of the previous milestone
102+
# was e.g. `2022-10-31T07:00:00Z` and `.next_day(14)` returns `2022-11-14T07:00:00Z` and we send that value
103+
# for the `due_on` field via the API, GitHub ends up creating a milestone with a due of `2022-11-13T08:00:00Z`
104+
# instead, introducing an off-by-one error on that due date.
105+
#
106+
# This is a bug in the GitHub API, not in our date computation logic.
107+
# To solve this, we trick it by forcing the time component of the ISO date we send to be `12:00:00Z`.
108+
options[:due_on] = newmilestone_duedate.strftime('%Y-%m-%dT12:00:00Z')
94109
options[:description] = comment
95110
github_client().create_milestone(repository, newmilestone_number, options)
96111
end

0 commit comments

Comments
 (0)