amitgaru2 / nepali-datetime

Python's core datetime inspired Bikram Sambat (BS date) & Nepal Time (NPT) package🇳🇵
https://pypi.org/project/nepali-datetime/
MIT License
61 stars 30 forks source link

Getting `day of month out of range` error. #14

Closed vector65536 closed 3 years ago

vector65536 commented 3 years ago

Hi. I have been getting this day of month out of range error when trying to convert date to nepali; and format time.

While rendering Jestha 31, 2077

import nepali_datetime
from datetime import timedelta, datetime

somedate = datetime(2020, 6, 13, 19, 15, 20, 231407) 
jeth_31 = nepali_datetime.date.from_datetime_date(somedate.date())
jeth_31.strftime("%d %N %Y")            
# 31 जेष्ठ

Meanwhile Jestha 32, 2077

otherdate = datetime(2020, 6, 14, 19, 15, 20, 231407) 
jeth_32 = nepali_datetime.date.from_datetime_date(otherdate.date())
jeth_32.strftime("%d %N %Y") 
# day of month out of range error

Dunno if this is related with (Nepali) months with 32 date or something in the package itself. If it helps, I am using Python 3.9, nepali-datetime 1.0.4.

Edit:: Update: Getting same error for Shrawan 32.

vector65536 commented 3 years ago

Hi. sorry for the late reply. Assuming the same code above,

jeth_31.strftime("%d %N %Y")          # produces '31 जेष्ठ 2077'

# Meanwhile
jeth_32.strftime("%d %N %Y")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\Python\Python39\lib\site-packages\nepali_datetime\__init__.py", line 422, in strftime
    return _wrap_strftime(self, fmt, self.timetuple())
  File "C:\Users\user\Python\Python39\lib\site-packages\nepali_datetime\__init__.py", line 130, in _wrap_strftime
    return _time.strftime(newformat, timetuple)
ValueError: day of month out of range
amitgaru2 commented 3 years ago

Fixed with v1.0.5.