slashmili / django-jalali

Jalali DateField support for Django model
http://pypi.python.org/pypi/django_jalali
BSD 3-Clause "New" or "Revised" License
254 stars 53 forks source link

jDateTimeField not parsing timezone from dumpdata json format #96

Closed ajahansh closed 3 years ago

ajahansh commented 5 years ago

django_jalali could not parse datetime in loaddata command. though dumpdata is working fine ("%H:%M:%S%z"). It seems that the problem might be not parsing %z in jdatetime, although django.utils.timezone.datetime does that.

$ from django.utils.timezone import datetime
$ from jdatetime import datetime as _jdatetime

$ datetime.strptime("23:59:03+0000", "%H:%M:%S%z")
$ datetime.datetime(1900, 1, 1, 23, 59, 3, tzinfo=datetime.timezone.utc)

$_jdatetime.strptime("23:59:03+0000", "%H:%M:%S%z")

ValueError: time data '23:59:03+0000' does not match format '%H:%M:%S%z'
ajahansh commented 5 years ago

It seems that this package is no longer actively supported. Better to stay away from it for the moment !

slashmili commented 5 years ago

Did you dump the database and now you want to restore it? If the answer is yes how did you do it? I haven't used Django for a long time.

BTW implementing timezone in jdatetime.datetime.strptime is quite complex. I created an issue for https://github.com/slashmili/python-jalali/issues/53

ajahansh commented 5 years ago

Yes, I dumped a model containing jDateTimeField. It gets dumped correctly as UTC: "23:59:03+0000", but it is unsuccessful in loaddata. +0000 can not be parsed.

dumpdata command

slashmili commented 3 years ago

I hope that in 2021 the issue is resolved! If anyone has the problem, please report it again.