Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django-jalali returned years in jalali but month and day in gregorian #142

Closed
tavallaie opened this issue Jul 26, 2021 · 2 comments
Closed

Comments

@tavallaie
Copy link

I have this query:

<jQuerySet [<SampleDate: test (1400-05-03 test ) >]>

when I filter by month=5, I get:

>> SampleDate.objects.filter(date__month=5)
<jQuerySet []>

but in the case of converting to the Gregorian, I get the result as follows:

>>> FoodDate.objects.filter(date__month=7)
<jQuerySet [<SampleDate: test (1400-05-03 test ) >

this bug only appears on month and day, not year:

>>> FoodDate.objects.filter(date__year=1400)
<jQuerySet [<SampleDate: test (1400-05-03 test ) >]>
  • Python version: 3.8
  • Django version: 3.0.8
  • django_jalali version:4.3.0
  • OS: ubuntu-20.04
@hramezani
Copy link
Collaborator

hramezani commented Jul 27, 2021

Thanks for reporting @tavallaie.

Django Jalali just supports __year filter. Behind the scene, it converts __year filter to __gte and __lte filter. Because it stores date and datetime in the gregorian format in the database. So, by filter(date__year=1400) Django Jalali converts it to
{'date__gte': jdatetime.datetime(1400, 1, 1, 0, 0), 'date__lte': jdatetime.datetime(1400, 12, 29, 23, 59, 59)}

But, for __month and __day and other date-related filters, we cannot do this conversion.

We can add a note to the readme file and inform users about this.

@slashmili
Copy link
Owner

closed due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants