Here I'm using Django and comparing timing. But I'm unable to do that. In the following code. wts value which is time value coming as a string. If it comes in string type then first I convert that in regular time after that I subtract 5 hours from it. and then compare if it is less than current or not..
if not wts:
raise ValueError('When to send(wts) require ')
if type(wts) is str:
wts_compare = parser.parse(wts)
print("wts time type ->>>" ,type(wts_compare),wts_compare)
wts = wts_compare - timedelta(hours=5)
if wts_compare <= timezone.now():
raise ValueError('when to send (wts) must be a future date-time')
else:
wts = wts-timedelta(hours=5)
if wts <= timezone.now():
raise ValueError('when to send (wts) must be a future date-time')