fix comparation datas put both in utc time
This commit is contained in:
parent
6fad773c91
commit
026a88acb8
|
@ -17,6 +17,7 @@ from datetime import datetime, timedelta, timezone
|
|||
from decimal import ROUND_HALF_EVEN, ROUND_UP, Decimal
|
||||
from typing import Optional, Set, Union
|
||||
from uuid import uuid4
|
||||
from dateutil.tz import tzutc
|
||||
|
||||
import inflection
|
||||
import teal.db
|
||||
|
@ -273,7 +274,7 @@ class Action(Thing):
|
|||
super().__init__(**kwargs)
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.end_time < other.end_time
|
||||
return self.end_time.replace(tzinfo=tzutc()) < other.end_time.replace(tzinfo=tzutc())
|
||||
|
||||
def __str__(self) -> str:
|
||||
return '{}'.format(self.severity)
|
||||
|
|
|
@ -73,10 +73,10 @@ class Action(Thing):
|
|||
@validates_schema
|
||||
def validate_times(self, data: dict):
|
||||
unix_time = datetime.fromisoformat("1970-01-02 00:00:00+00:00")
|
||||
if 'end_time' in data and data['end_time'] < unix_time:
|
||||
if 'end_time' in data and data['end_time'].replace(tzinfo=tzutc()) < unix_time:
|
||||
data['end_time'] = unix_time
|
||||
|
||||
if 'start_time' in data and data['start_time'] < unix_time:
|
||||
if 'start_time' in data and data['start_time'].replace(tzinfo=tzutc()) < unix_time:
|
||||
data['start_time'] = unix_time
|
||||
|
||||
if data.get('end_time') and data.get('start_time'):
|
||||
|
|
Reference in New Issue