amitgaru2 / nepali-datetime Goto Github PK
View Code? Open in Web Editor NEWPython's core datetime inspired Bikram Sambat (BS date) & Nepal Time (NPT) package🇳🇵
Home Page: https://pypi.org/project/nepali-datetime/
License: MIT License
Python's core datetime inspired Bikram Sambat (BS date) & Nepal Time (NPT) package🇳🇵
Home Page: https://pypi.org/project/nepali-datetime/
License: MIT License
Sorry for this question, I know this is not a good platform for asking question. Actually I want to build a calendar using django same as below.
.
I've no idea, how to achieve this one. So can you please share some idea, or guide , that can help me to achieve this. and the last question is how can i use this package in my project. Please give me some idea, I wan't to learn some things in this lock down period.
I'm using django, and python default HTML Calendar modules and here is my progress.
hello there. I have also had experience with this package also (Nepali: v 0.4.1) in pip.
however I love this module and seen how this has evolved..!
If its not asking too much, can we have more features -
AD to BS and vice versa converter,,
months' name in Nepali (unicode) also..
strfdate and time nepali (unicode) as well..
render nepali calendar with tabbed/spacing month view (np/en)...
thanks for adding more datetime operations.. I have starred this project for your effort.
Firstly, this is a great package. thanks for development. I just want to give a feedback from this thread.
Nepali months name is incorrectly displayed. I believe this is how they should be named.
Also, what about adding some more mathematical operations on the Nepali date and time?
So, I checked and found that while using the strptime() method, the %N
directive does not work.
Here are some snippets of the error
>>> d = "चैत्र"
>>> e = ndt.datetime.now().strftime("%N")
>>> d
'चैत्र'
>>> e
'चैत्र'
>>> z = ndt.datetime.strptime(d, "%N")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sthasam/Programming/investo_backend/.venv/lib/python3.8/site-packages/nepali_datetime/__init__.py", line 828, in strptime
return _custom_strptime._strptime_datetime(cls, date_string, format)
File "/home/sthasam/Programming/investo_backend/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 295, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/home/sthasam/Programming/investo_backend/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 135, in _strptime
raise ValueError("'%s' is a bad directive in format '%s'" %
ValueError: 'N' is a bad directive in format '%N'
>>> d == e
True
>>> z = ndt.datetime.strptime(e, "%N")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/__init__.py", line 828, in strptime
return _custom_strptime._strptime_datetime(cls, date_string, format)
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 295, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 135, in _strptime
raise ValueError("'%s' is a bad directive in format '%s'" %
ValueError: 'N' is a bad directive in format '%N'
As you can see, I tried two strings with the strptime
d
Both do not work with strptime.
>>> f = "वैशाख"
>>> g = ndt.datetime(2000,1,1).strftime("%N")
>>> f
'वैशाख'
>>> g
'वैशाख'
>>> f==g
True
>>> m = ndt.datetime.strptime(f, "%N")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/__init__.py", line 828, in strptime
return _custom_strptime._strptime_datetime(cls, date_string, format)
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 295, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/home/sthasam/Programming/.venv/lib/python3.8/site-packages/nepali_datetime/_custom_strptime.py", line 135, in _strptime
raise ValueError("'%s' is a bad directive in format '%s'" %
ValueError: 'N' is a bad directive in format '%N'
Same example as above but with a different month.
I looked into the code of the project and noticed that there the date limited to 2100 bs. I need to implement dates greater than 2100 B.S. for a project. I will be implementing those dates. I will be willing to contribute. Let me know what you think.
Currently, %y for any year 'xx' > 68 gives 19xx.
While the open group spec does suggest the range [69, 99] to be the year 1900s, it feels a tad bit foolish in the case of Nepali year, no? We're at 2077 currently; so I think that suggestion should be disregarded and updated accordingly.
When you do nepali_datetime.date.from_datetime_date(datetime.date(2024, 7, 15))
, the result is 2081-3-32, which is not a valid date.
a feature to get AD version of current Nepali fiscal year.
(basically AD dates of gone Shrawan 1 and upcoming Asar masantar).
feature display current year's Baisakh 1 in AD and chaitra masantar in AD.
feature to display current F/Y's start and end date (fy_start, fy_end in AD).
feature to display current F/Y's N months (fy start, fy N months):
example when N = 10, return date (AD) of gone Shrawan 1 and coming Baisakh masantar (i.e the last date of N=10).
add flag to return (i) dates (fy start, fy end as above), OR (ii) a list of months (e.g. [Shrawan, Bharda, ... , Baisakh])
similarly, display previous and next fiscal years start and end AD dates.
please feel free to improvise the suggestion/request. Thanks
Currently doesn't support nepali unicode Time directives.
i.e. so Time is displayed only in english literals like 01:22PM and not ०१:२२
ATM the nepali_datetime.date.today() is returning date based on the timezone of the machine. While the correct date to be returned should be always based on Nepal Time zone +05:45.
As I see, the timestamp() has not been implemented as of yet. Putting this issue out there so devs out there can contribute to this issue.
>>> (nepali_datetime.datetime(2079, 8, 17) - nepali_datetime.datetime(2062, 8, 17)).days/365
17.013698630136986
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.
Can we get an implementation of "%U" flag as present in datetime to get the Week number of the year (Sunday as the first day of the week) for Nepali dates?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.