Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
('%Y-%m-%d', 3),
]
for format, c in formats:
try: # Seconds are optional, so try converting seconds first.
t = time.strptime(datetime_obj, format)
if t.tm_year > 1700:
return datetime.datetime(
*time.strptime(datetime_obj, format)[:c],
**kwargs)
else:
return jdatetime.datetime(
*time.strptime(datetime_obj, format)[:c],
**kwargs)
except ValueError:
try:
return jdatetime.datetime.strptime(
datetime_obj,
'%Y-%m-%d %H:%M'
).replace(**kwargs)
except ValueError:
pass
raise exceptions.ValidationError(self.error_messages['invalid'])
def strptime(self, value, format):
return jalali_datetime.strptime(force_str(value), format).togregorian()
def strptime(self, value, format):
return jalali_datetime.strptime(force_str(value), format).togregorian().date()