1818import pykern .pkcollections
1919import os
2020import os .path
21+ import pykern .pkcompat
2122import re
2223import subprocess
2324import sys
@@ -268,7 +269,7 @@ def issue_update_alpha_pending(repo):
268269 g .login ()
269270 for c in r .commits (
270271 sha = "master" ,
271- since = datetime . datetime . now () - datetime .timedelta (minutes = 24 * 60 ),
272+ since = pykern . pkcompat . utcnow () - datetime .timedelta (minutes = 24 * 60 ),
272273 ):
273274 m = re .search (r"([-\w]+/[-\w]+)?#(\d+)" , c .message )
274275 if not m :
@@ -421,7 +422,7 @@ def _repos():
421422 return _try (lambda : self .list_org_repos (org , include_forks = True ))
422423
423424 # POSIT: timestamps are sorted in _clone()
424- self ._date_d = datetime . datetime . now ().strftime ("%Y%m%d%H%M%S" )
425+ self ._date_d = pykern . pkcompat . utcnow ().strftime ("%Y%m%d%H%M%S" )
425426 with pkio .save_chdir (self ._date_d , mkdir = True ):
426427 for r in _repos ():
427428 pkdlog ("{}: begin" , r .full_name )
@@ -438,9 +439,9 @@ def _prev_backup(self, base, ext):
438439 return b [- 1 ] if b else []
439440
440441 def _purge (self ):
441- expires = datetime . datetime .utcnow () - cfg .keep_days
442+ expires = pykern . pkcompat .utcnow () - cfg .keep_days
442443 for d in pkio .sorted_glob ("[0-9]" * len (self ._date_d )):
443- t = datetime .datetime .utcfromtimestamp (d .stat ().mtime )
444+ t = datetime .datetime .fromtimestamp (d .stat ().mtime , datetime . timezone . utc )
444445 if t < expires :
445446 pkio .unchecked_remove (d )
446447
@@ -488,7 +489,7 @@ def _issue(i, d):
488489 k = PKDict (state = "all" )
489490 if prev :
490491 self ._extract_backup (prev )
491- k .since = datetime . datetime . now () - datetime .timedelta (days = 7 )
492+ k .since = pykern . pkcompat . utcnow () - datetime .timedelta (days = 7 )
492493 for i in _try (lambda : list (repo .issues (** k ))):
493494 _try (lambda : _issue (i , d ))
494495 _tar (base )
@@ -627,7 +628,7 @@ def _release_title(channel, pending=False):
627628 x = (
628629 "[pending]"
629630 if pending
630- else datetime . datetime .utcnow ()
631+ else pykern . pkcompat .utcnow ()
631632 .replace (
632633 microsecond = 0 ,
633634 )
0 commit comments