slashmili / python-jalali

Jalali calendar binding for Python based on Python's datetime module
http://pypi.python.org/pypi/jdatetime/
Other
335 stars 46 forks source link

datetime and jdatetime pass diffrent returns #131

Closed MohammadSafaeii closed 1 year ago

MohammadSafaeii commented 1 year ago

in datetime library, %% counts as % char so datetime.now().strftime('%%d') returns '%d' and don't consider %d as date number but jdatetime will replace every %d in string therefore jdatetime.datetime.now().strftime('%%d') returns '%08'

we can use more % for example datetime.now().strftime('%%%%%%d') returns '%%%d' but jdatetime.datetime.now().strftime('%%%%%%d') returns '%%%%%08'

datetime.now().strftime('%%%%%d') returns '%%29' jdatetime.datetime.now().strftime('%%%%%d') returns '%%%%08'

hramezani commented 1 year ago

@MohammadSafaeii Thanks for reporting. Yes, you are right we are not consistent here and it has to be fixed.

Do you have any solution? Would you like to work on it and prepare a patch?

MohammadSafaeii commented 1 year ago

I tried to replace every % with %% then use this regex ([^%-]((%%)*)-?)({posix_list[i]}) but it still have some bugs and i couldn't handle it with regex datetime checks string's characters 1 by 1 in loop, i think its better solution

slashmili commented 1 year ago

@MohammadSafaeii it's fixed in the main. I'll publish the fix in the next days