Closed TahaJahani closed 11 months ago
@TahaJahani what is the error you've got?
I've tried it and didn't get any errors.
Python 3.10.10 (main, Mar 13 2023, 15:19:57) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jdatetime
>>> ct = jdatetime.datetime.utcnow()
>>> ct
jdatetime.datetime(1402, 5, 2, 20, 21, 21, 471030)
>>> print(jdatetime.datetime.strptime(ct.strftime('%y/%m/%d'), '%y/%m/%d'))
1402-05-02 00:00:00
seem like an issue in 3.6.2
Python 3.11.4 (main, Jun 15 2023, 07:29:58) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jdatetime
>>> jdatetime.__VERSION__
'3.6.2'
>>> ct = jdatetime.datetime.utcnow()
>>> print(jdatetime.datetime.strptime(ct.strftime('%y/%m/%d'), '%y/%m/%d'))
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/jdatetime/__init__.py", line 916, in strptime
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/site-packages/jdatetime/__init__.py", line 927, in strptime
raise ValueError(
ValueError: time data '02/05/11' does not match format '%y/%m/%d'
Python 3.10.12 (main, Jun 15 2023, 07:13:36) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jdatetime
>>> jdatetime.__VERSION__
'4.1.1'
>>> ct = jdatetime.datetime.utcnow()
>>> print(jdatetime.datetime.strptime(ct.strftime('%y/%m/%d'), '%y/%m/%d'))
1402-05-11 00:00:00
>>>
Just now tested the example with 3.8.2
and it works!
Please upgrade the minor package.
>>> import jdatetime
>>> jdatetime.__VERSION__
'3.8.2'
>>> ct = jdatetime.datetime.utcnow()
>>> print(jdatetime.datetime.strptime(ct.strftime('%y/%m/%d'), '%y/%m/%d'))
1402-05-11 00:00:00
Thanks for your support
Please include your runtime information
The parser seems to have trouble parsing strings in "%y/%m/%d" formats. To reproduce the bug, run the following code: