Correcting import to allow using datetime.timezone.utc

datetime.timezone.utc isn't accessible in case of
'from datetime import datetime'. Switching to
'import datetime'.

Change-Id: I8aa94fcd7e7285187939e940186876023fc48119
Signed-off-by: Ivan Anfimov <lazekteam@gmail.com>
This commit is contained in:
Ivan Anfimov
2026-06-19 17:38:32 +00:00
parent 7fe185e0b7
commit fb4524c156
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
import datetime
from datetime import timezone
from itertools import chain
import json
@@ -207,6 +207,6 @@ def _parse_api_datestr(datestr):
if datestr is None:
return datestr
dateobj = datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%S.%f")
dateobj = datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%S.%f")
return dateobj.replace(tzinfo=timezone.utc)
+3 -2
View File
@@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from datetime import datetime
import datetime
from datetime import timezone
from functools import partial
@@ -42,7 +43,7 @@ class UpdateLease(tables.LinkAction):
classes = ("btn-create", "ajax-modal")
def allowed(self, request, lease):
if datetime.strptime(lease.end_date, '%Y-%m-%dT%H:%M:%S.%f').\
if datetime.datetime.strptime(lease.end_date, '%Y-%m-%dT%H:%M:%S.%f').\
replace(tzinfo=timezone.utc) > datetime.now(timezone.utc):
return True
return False