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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user