mirror of https://github.com/apache/lucene.git
Updated releaseWizard.py to use timezone-aware objects to represent datetimes in UTC (#14102)
Co-authored-by: Shubham Sharma <shubhamvibrantiit@gmail.com>
This commit is contained in:
parent
0169c1efea
commit
3fad719337
|
@ -49,6 +49,7 @@ import urllib
|
|||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from datetime import timezone
|
||||
|
||||
try:
|
||||
import holidays
|
||||
|
@ -99,7 +100,7 @@ def expand_jinja(text, vars=None):
|
|||
'state': state,
|
||||
'gpg_key' : state.get_gpg_key(),
|
||||
'gradle_cmd' : 'gradlew.bat' if is_windows() else './gradlew',
|
||||
'epoch': unix_time_millis(datetime.utcnow()),
|
||||
'epoch': unix_time_millis(datetime.now(tz=timezone.utc)),
|
||||
'get_next_version': state.get_next_version(),
|
||||
'current_git_rev': state.get_current_git_rev(),
|
||||
'keys_downloaded': keys_downloaded(),
|
||||
|
@ -199,7 +200,7 @@ def check_prerequisites(todo=None):
|
|||
return True
|
||||
|
||||
|
||||
epoch = datetime.utcfromtimestamp(0)
|
||||
epoch = datetime.fromtimestamp(timestamp=0, tz=timezone.utc)
|
||||
|
||||
|
||||
def unix_time_millis(dt):
|
||||
|
@ -279,7 +280,7 @@ class ReleaseState:
|
|||
self.latest_version = None
|
||||
self.previous_rcs = {}
|
||||
self.rc_number = 1
|
||||
self.start_date = unix_time_millis(datetime.utcnow())
|
||||
self.start_date = unix_time_millis(datetime.now(tz=timezone.utc))
|
||||
self.script_branch = run("git rev-parse --abbrev-ref HEAD").strip()
|
||||
self.mirrored_versions = None
|
||||
try:
|
||||
|
@ -741,7 +742,7 @@ class Todo(SecretYamlObject):
|
|||
|
||||
def set_done(self, is_done):
|
||||
if is_done:
|
||||
self.state['done_date'] = unix_time_millis(datetime.utcnow())
|
||||
self.state['done_date'] = unix_time_millis(datetime.now(tz=timezone.utc))
|
||||
if self.persist_vars:
|
||||
for k in self.persist_vars:
|
||||
self.state[k] = self.get_vars()[k]
|
||||
|
@ -935,7 +936,7 @@ def expand_multiline(cmd_txt, indent=0):
|
|||
|
||||
|
||||
def unix_to_datetime(unix_stamp):
|
||||
return datetime.utcfromtimestamp(unix_stamp / 1000)
|
||||
return datetime.fromtimestamp(timestamp=unix_stamp / 1000, tz=timezone.utc)
|
||||
|
||||
|
||||
def generate_asciidoc():
|
||||
|
@ -949,7 +950,7 @@ def generate_asciidoc():
|
|||
|
||||
fh.write("= Lucene Release %s\n\n" % state.release_version)
|
||||
fh.write("(_Generated by releaseWizard.py v%s at %s_)\n\n"
|
||||
% (getScriptVersion(), datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC")))
|
||||
% (getScriptVersion(), datetime.now(tz=timezone.utc).strftime("%Y-%m-%d %H:%M UTC")))
|
||||
fh.write(":numbered:\n\n")
|
||||
fh.write("%s\n\n" % template('help'))
|
||||
for group in state.todo_groups:
|
||||
|
@ -1839,9 +1840,9 @@ def create_ical(todo): # pylint: disable=unused-argument
|
|||
return True
|
||||
|
||||
|
||||
today = datetime.utcnow().date()
|
||||
today = datetime.now(tz=timezone.utc).date()
|
||||
sundays = {(today + timedelta(days=x)): 'Sunday' for x in range(10) if (today + timedelta(days=x)).weekday() == 6}
|
||||
y = datetime.utcnow().year
|
||||
y = datetime.now(tz=timezone.utc).year
|
||||
years = [y, y+1]
|
||||
non_working = holidays.CA(years=years) + holidays.US(years=years) + holidays.UK(years=years) \
|
||||
+ holidays.DE(years=years) + holidays.NO(years=years) + holidays.IN(years=years) + holidays.RU(years=years)
|
||||
|
@ -1849,7 +1850,7 @@ non_working = holidays.CA(years=years) + holidays.US(years=years) + holidays.UK(
|
|||
|
||||
def vote_close_72h_date():
|
||||
# Voting open at least 72 hours according to ASF policy
|
||||
return datetime.utcnow() + timedelta(hours=73)
|
||||
return datetime.now(tz=timezone.utc) + timedelta(hours=73)
|
||||
|
||||
|
||||
def vote_close_72h_holidays():
|
||||
|
|
Loading…
Reference in New Issue