npdatetime 0.1.1__py3-none-any.whl → 0.2.0.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- npdatetime/__init__.py +9 -1
- npdatetime/utils.py +9 -0
- npdatetime-0.2.0.dev2.dist-info/METADATA +273 -0
- npdatetime-0.2.0.dev2.dist-info/RECORD +11 -0
- npdatetime-0.1.1.dist-info/METADATA +0 -180
- npdatetime-0.1.1.dist-info/RECORD +0 -10
- {npdatetime-0.1.1.dist-info → npdatetime-0.2.0.dev2.dist-info}/LICENSE +0 -0
- {npdatetime-0.1.1.dist-info → npdatetime-0.2.0.dev2.dist-info}/WHEEL +0 -0
- {npdatetime-0.1.1.dist-info → npdatetime-0.2.0.dev2.dist-info}/top_level.txt +0 -0
npdatetime/__init__.py
CHANGED
|
@@ -15,6 +15,8 @@ import time as _time
|
|
|
15
15
|
import math as _math
|
|
16
16
|
import datetime as _actual_datetime
|
|
17
17
|
|
|
18
|
+
from npdatetime.utils import get_fiscal_year_by_date
|
|
19
|
+
|
|
18
20
|
from .config import CALENDAR_PATH, MINDATE, MAXDATE, REFERENCE_DATE_AD
|
|
19
21
|
|
|
20
22
|
MINYEAR = MINDATE['year']
|
|
@@ -376,7 +378,13 @@ class date:
|
|
|
376
378
|
if not isinstance(from_date, _actual_datetime.date):
|
|
377
379
|
raise TypeError("Unsupported type {}.".format(type(from_date)))
|
|
378
380
|
return cls(MINYEAR, 1, 1) + (from_date - _actual_datetime.date(**REFERENCE_DATE_AD))
|
|
379
|
-
|
|
381
|
+
|
|
382
|
+
@classmethod
|
|
383
|
+
def current_fiscal_year(cls):
|
|
384
|
+
"""Return the current fiscal year"""
|
|
385
|
+
current_date = cls.today()
|
|
386
|
+
return get_fiscal_year_by_date(current_date)
|
|
387
|
+
|
|
380
388
|
def to_datetime_date(self):
|
|
381
389
|
"""Convert npdatetime.date to datetime.date (B.S date to A.D).
|
|
382
390
|
|
npdatetime/utils.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
def get_fiscal_year_by_date(date_obj):
|
|
3
|
+
"""Return fiscal year by the given Nepali datetime object"""
|
|
4
|
+
# Fiscal year starts in Shrawan (month 4)
|
|
5
|
+
if date_obj.month < 4: # Months 1, 2, 3 are part of the previous fiscal year
|
|
6
|
+
fiscal_year = (date_obj.year - 1, date_obj.year)
|
|
7
|
+
else:
|
|
8
|
+
fiscal_year = (date_obj.year, date_obj.year + 1)
|
|
9
|
+
return fiscal_year
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: npdatetime
|
|
3
|
+
Version: 0.2.0.dev2
|
|
4
|
+
Summary: A Python package that provides advanced functionality for handling Nepali dates and times, including support for the Bikram Sambat calendar system and Nepal Time (NPT). Ideal for developers working with Nepali date-related applications, offering seamless conversion, manipulation, and formatting of dates and times in the Nepali calendar.
|
|
5
|
+
Home-page: https://github.com/4mritGiri/npdatetime
|
|
6
|
+
Author: Amrit Giri
|
|
7
|
+
Author-email: Amrit Giri <amritgiri02595@gmail.com>
|
|
8
|
+
License: The MIT License (MIT)
|
|
9
|
+
Copyright © 2020 AMRIT GIRI
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
|
19
|
+
all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
+
THE SOFTWARE.
|
|
28
|
+
Project-URL: Homepage, https://github.com/4mritGiri/npdatetime#readme
|
|
29
|
+
Project-URL: Issues, https://github.com/4mritGiri/npdatetime/issues
|
|
30
|
+
Keywords: Nepali Date,Date Conversion,Datetime,Bikram Sambat,Bikram Samvat,nepali,B.S.,BS,bs,b.s,date,NpDateTime,datetime,time,timezone,nepal,bikram,sambat,samvat,nepali-date,nepali-datetime,nepal-time,npt,nepal-timezone,npdatetime,npdt
|
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Requires-Python: >=3.5
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
License-File: LICENSE
|
|
37
|
+
|
|
38
|
+
# **Nepali Datetime (Bikram Sambat Date & Nepal Time)**
|
|
39
|
+
|
|
40
|
+
A Python library inspired by Python's core `datetime` module, designed specifically for operations based on the **Bikram Sambat (B.S.)** calendar and **Nepal Time (NPT)** timezone (`UTC+05:45`).
|
|
41
|
+
|
|
42
|
+
This library bridges the gap between traditional Nepali dates and modern software development, allowing developers to handle Nepali dates with ease while maintaining compatibility with Python's `datetime`.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## **Key Features**
|
|
47
|
+
|
|
48
|
+
- Full support for Bikram Sambat (B.S.) date operations.
|
|
49
|
+
- Handles Nepal Time (NPT) seamlessly (`UTC+05:45`).
|
|
50
|
+
- Built-in compatibility with Python's `datetime` module.
|
|
51
|
+
- Supports date formatting with Nepali Unicode for localized output.
|
|
52
|
+
- Conversion between Bikram Sambat and Gregorian calendars.
|
|
53
|
+
- Convenient utilities for date parsing, arithmetic, and calendars.
|
|
54
|
+
- Compatible with Python 3.5 and above.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## **Installation**
|
|
59
|
+
|
|
60
|
+
Install the package via `pip`:
|
|
61
|
+
```bash
|
|
62
|
+
pip install npdatetime
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## **Quick Start**
|
|
68
|
+
|
|
69
|
+
Here's how you can use `npdatetime` alongside Python's standard `datetime` module:
|
|
70
|
+
|
|
71
|
+
### **Importing**
|
|
72
|
+
```python
|
|
73
|
+
import datetime
|
|
74
|
+
import npdatetime
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### **Getting Today's Date**
|
|
78
|
+
```python
|
|
79
|
+
# Gregorian date
|
|
80
|
+
datetime.date.today()
|
|
81
|
+
|
|
82
|
+
# Bikram Sambat date
|
|
83
|
+
npdatetime.date.today()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### **Current Date and Time**
|
|
87
|
+
```python
|
|
88
|
+
# Gregorian datetime
|
|
89
|
+
datetime.datetime.now()
|
|
90
|
+
|
|
91
|
+
# Bikram Sambat datetime
|
|
92
|
+
npdatetime.datetime.now()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## **Key Functionalities**
|
|
98
|
+
|
|
99
|
+
### **Creating Date and Datetime Objects**
|
|
100
|
+
```python
|
|
101
|
+
# Gregorian date
|
|
102
|
+
datetime.date(2020, 9, 4)
|
|
103
|
+
|
|
104
|
+
# Bikram Sambat date
|
|
105
|
+
npdatetime.date(2077, 5, 19)
|
|
106
|
+
|
|
107
|
+
# Gregorian datetime
|
|
108
|
+
datetime.datetime(2020, 9, 4, 8, 26, 10, 123456)
|
|
109
|
+
|
|
110
|
+
# Bikram Sambat datetime
|
|
111
|
+
npdatetime.datetime(2077, 5, 19, 8, 26, 10, 123456)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### **Date Formatting with Localization**
|
|
115
|
+
```python
|
|
116
|
+
# Formatting a Bikram Sambat date
|
|
117
|
+
npdatetime.datetime(2077, 5, 19).strftime("%d %B %Y")
|
|
118
|
+
# Output: 19 Bhadau 2077
|
|
119
|
+
|
|
120
|
+
# Formatting with Nepali Unicode
|
|
121
|
+
npdatetime.date(2077, 10, 25).strftime('%K-%n-%D (%k %N %G)')
|
|
122
|
+
# Output: २०७७-१०-२५ (२५ माघ आइतबार)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### **Parsing Dates from Strings**
|
|
126
|
+
```python
|
|
127
|
+
npdatetime.datetime.strptime('2077-09-12', '%Y-%m-%d')
|
|
128
|
+
# Output: npdatetime.datetime(2077, 9, 12, 0, 0)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### **Timedelta Operations**
|
|
132
|
+
```python
|
|
133
|
+
# Adding days to a date
|
|
134
|
+
npdatetime.date(1990, 5, 10) + datetime.timedelta(days=350)
|
|
135
|
+
# Output: npdatetime.date(1991, 4, 26)
|
|
136
|
+
|
|
137
|
+
# Adding hours and minutes to a datetime
|
|
138
|
+
npdatetime.datetime(1990, 5, 10, 5, 10) + datetime.timedelta(hours=3, minutes=15)
|
|
139
|
+
# Output: npdatetime.datetime(1990, 5, 10, 8, 25)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### **Bikram Sambat <-> Gregorian Conversion**
|
|
143
|
+
```python
|
|
144
|
+
# Convert Bikram Sambat to Gregorian
|
|
145
|
+
npdatetime.date(1999, 7, 25).to_datetime_date()
|
|
146
|
+
# Output: datetime.date(1942, 11, 10)
|
|
147
|
+
|
|
148
|
+
# Convert Gregorian to Bikram Sambat
|
|
149
|
+
npdatetime.date.from_datetime_date(datetime.date(1942, 11, 10))
|
|
150
|
+
# Output: npdatetime.date(1999, 7, 25)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### **Bikram Sambat Monthly Calendar**
|
|
154
|
+
```python
|
|
155
|
+
npdatetime.date(2078, 1, 1).calendar()
|
|
156
|
+
|
|
157
|
+
# Output:
|
|
158
|
+
Baishakh 2078
|
|
159
|
+
Sun Mon Tue Wed Thu Fri Sat
|
|
160
|
+
1 2 3 4
|
|
161
|
+
5 6 7 8 9 10 11
|
|
162
|
+
12 13 14 15 16 17 18
|
|
163
|
+
19 20 21 22 23 24 25
|
|
164
|
+
26 27 28 29 30 31
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## **Fiscal Year Calculations**
|
|
170
|
+
|
|
171
|
+
The **npdatetime** library provides methods to easily calculate the current fiscal year and convert dates to their corresponding fiscal year. Fiscal years in Nepal start from **Shrawan (month 4)** and end at **Ashadh (month 12)**.
|
|
172
|
+
|
|
173
|
+
### **Getting the Current Fiscal Year**
|
|
174
|
+
You can get the current fiscal year using the `current_fiscal_year()` method. It returns the fiscal year as a tuple in the format `(start_year, end_year)`.
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
import npdatetime
|
|
178
|
+
|
|
179
|
+
# Get current fiscal year
|
|
180
|
+
npdatetime.datetime.current_fiscal_year()
|
|
181
|
+
# Output: (2081, 2082)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Alternatively, you can use it directly from the `datetime` class:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from npdatetime import datetime
|
|
188
|
+
|
|
189
|
+
# Get current fiscal year
|
|
190
|
+
datetime.current_fiscal_year()
|
|
191
|
+
# Output: (2081, 2082)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### **Getting Fiscal Year for a Specific Date**
|
|
195
|
+
You can also calculate the fiscal year for any specific Nepali date using the `get_fiscal_year_by_date()` function. This takes a `datetime` object as input and returns the fiscal year for that date.
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from npdatetime import get_fiscal_year_by_date
|
|
199
|
+
from npdatetime import datetime
|
|
200
|
+
|
|
201
|
+
# Example date
|
|
202
|
+
date_obj = datetime(2079, 12, 1)
|
|
203
|
+
|
|
204
|
+
# Get fiscal year for a specific date
|
|
205
|
+
get_fiscal_year_by_date(date_obj)
|
|
206
|
+
# Output: (2079, 2080)
|
|
207
|
+
|
|
208
|
+
# You can also directly pass a Nepali datetime object to the function
|
|
209
|
+
get_fiscal_year_by_date(datetime(2080, 4, 1))
|
|
210
|
+
# Output: (2080, 2081)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### **Examples**
|
|
214
|
+
|
|
215
|
+
Here are a few examples of how you can use the `get_fiscal_year_by_date()` method to calculate the fiscal year for various dates:
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
# For 2079-12-01
|
|
219
|
+
get_fiscal_year_by_date(datetime(2079, 12, 1))
|
|
220
|
+
# Output: (2079, 2080)
|
|
221
|
+
|
|
222
|
+
# For 2080-03-01
|
|
223
|
+
get_fiscal_year_by_date(datetime(2080, 3, 1))
|
|
224
|
+
# Output: (2079, 2080)
|
|
225
|
+
|
|
226
|
+
# For 2080-04-01
|
|
227
|
+
get_fiscal_year_by_date(datetime(2080, 4, 1))
|
|
228
|
+
# Output: (2080, 2081)
|
|
229
|
+
|
|
230
|
+
# For 2080-06-01
|
|
231
|
+
get_fiscal_year_by_date(datetime(2080, 6, 1))
|
|
232
|
+
# Output: (2080, 2081)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### **Note**
|
|
236
|
+
- The fiscal year is based on the Nepali date system, which is different from the Gregorian calendar. In Nepal, the fiscal year runs from **Shrawan (month 4)** to **Ashadh (month 12)**.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## **Documentation**
|
|
241
|
+
|
|
242
|
+
Comprehensive usage examples and detailed documentation can be found on the [official website](https://4mritGiri.github.io/npdatetime/).
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## **Contributing**
|
|
247
|
+
|
|
248
|
+
We welcome contributions! If you'd like to contribute, check out the [CONTRIBUTING.md](https://github.com/4mritGiri/npdatetime/blob/master/CONTRIBUTING.md) guide for details on how to get started.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## **License**
|
|
253
|
+
|
|
254
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## **Feedback & Support**
|
|
259
|
+
|
|
260
|
+
For feature requests, bug reports, or feedback, please create an issue on the [GitHub repository](https://github.com/4mritGiri/npdatetime/issues).
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### 🌟 **Made for Developers, by Developers** 🌟
|
|
265
|
+
Your feedback and support are invaluable in making **npdatetime** the go-to library for working with Nepali dates. Thank you! 🙌
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### **Improvements in This Version**
|
|
270
|
+
1. Enhanced structure with logical sections for better readability.
|
|
271
|
+
2. Highlighted key functionalities for quick reference.
|
|
272
|
+
3. Added friendly language to engage contributors and users.
|
|
273
|
+
4. Updated examples to be more illustrative and user-friendly.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
npdatetime/__init__.py,sha256=jwHLOIQFp4WIL2KDAudEcVB-_5un2wjQJNPNu2nxYA4,38205
|
|
2
|
+
npdatetime/__init__.pyi,sha256=JOPIVFiqz6eoxNpPGO9LETNLLf_YPJL5wnvmLN3eq9U,10106
|
|
3
|
+
npdatetime/_custom_strptime.py,sha256=sO1CkAJV_4Ahgr0cqJjc4HncihVt0S0KzoKIblDYZMw,12014
|
|
4
|
+
npdatetime/config.py,sha256=C-ozgMViZyhbIUtP1phZ-xshktPwdbsVssFUTYVP6Os,396
|
|
5
|
+
npdatetime/utils.py,sha256=ZsoAe8mcsKk5aDLOIaUa-IpFBPhtQVi1M4Q2dV_cvs0,371
|
|
6
|
+
npdatetime/data/calendar_bs.csv,sha256=G9KWbb35Ietcz31K2E4R5J2a5rhQl0QJjw1TA_V4M8s,5250
|
|
7
|
+
npdatetime-0.2.0.dev2.dist-info/LICENSE,sha256=zVhPTICUPJU67BU1DoMb0SofU9Zo2uY1kV-jn2SqvfI,1082
|
|
8
|
+
npdatetime-0.2.0.dev2.dist-info/METADATA,sha256=iOQZUVAcQLp9Lk0-txm1kGpjcRq33R8RZ7TidTYCxUY,9143
|
|
9
|
+
npdatetime-0.2.0.dev2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
10
|
+
npdatetime-0.2.0.dev2.dist-info/top_level.txt,sha256=2FR7RutVmSD6SL-iOwUcGrHd1XXgzaqUvAU78WGz_9g,11
|
|
11
|
+
npdatetime-0.2.0.dev2.dist-info/RECORD,,
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: npdatetime
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Summary: A Python package that provides advanced functionality for handling Nepali dates and times, including support for the Bikram Sambat calendar system and Nepal Time (NPT). Ideal for developers working with Nepali date-related applications, offering seamless conversion, manipulation, and formatting of dates and times in the Nepali calendar.
|
|
5
|
-
Home-page: https://github.com/4mritGiri/npdatetime
|
|
6
|
-
Author: Amrit Giri
|
|
7
|
-
Author-email: Amrit Giri <amritgiri02595@gmail.com>
|
|
8
|
-
License: The MIT License (MIT)
|
|
9
|
-
Copyright © 2020 AMRIT GIRI
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the “Software”), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in
|
|
19
|
-
all copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
-
THE SOFTWARE.
|
|
28
|
-
Project-URL: Homepage, https://github.com/4mritGiri/npdatetime#readme
|
|
29
|
-
Project-URL: Issues, https://github.com/4mritGiri/npdatetime/issues
|
|
30
|
-
Keywords: Nepali Date,Date Conversion,Datetime,Bikram Sambat,Bikram Samvat,nepali,B.S.,BS,bs,b.s,date,NpDateTime,datetime,time,timezone,nepal,bikram,sambat,samvat,nepali-date,nepali-datetime,nepal-time,npt,nepal-timezone,npdatetime,npdt
|
|
31
|
-
Classifier: Programming Language :: Python :: 3
|
|
32
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
-
Classifier: Operating System :: OS Independent
|
|
34
|
-
Requires-Python: >=3.5
|
|
35
|
-
Description-Content-Type: text/markdown
|
|
36
|
-
License-File: LICENSE
|
|
37
|
-
|
|
38
|
-
# **Nepali Datetime (Bikram Sambat Date & Nepal Time)**
|
|
39
|
-
|
|
40
|
-
A Python library inspired by the core `datetime` module, designed for operations based on the **Bikram Sambat (B.S.)** calendar and **Nepal Time (NPT)** timezone (`UTC+05:45`).
|
|
41
|
-
|
|
42
|
-
### **Key Features**
|
|
43
|
-
- Supports Bikram Sambat (B.S.) date operations.
|
|
44
|
-
- Handles Nepal Time (NPT) timezone.
|
|
45
|
-
- Compatible with Python 3.5+.
|
|
46
|
-
- Seamless integration with Python's native `datetime` functionalities.
|
|
47
|
-
- Support for date formatting with Nepali Unicode.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## **Installation**
|
|
52
|
-
|
|
53
|
-
Install the package using `pip`:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
pip install npdatetime
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## **Basic Usage**
|
|
62
|
-
|
|
63
|
-
Here's how you can use `npdatetime` alongside Python's `datetime`:
|
|
64
|
-
|
|
65
|
-
### **Importing**
|
|
66
|
-
```python
|
|
67
|
-
import datetime
|
|
68
|
-
import npdatetime
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### **Getting Today's Date**
|
|
72
|
-
```python
|
|
73
|
-
# Gregorian date
|
|
74
|
-
datetime.date.today()
|
|
75
|
-
|
|
76
|
-
# Bikram Sambat date
|
|
77
|
-
npdatetime.date.today()
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### **Current Date and Time**
|
|
81
|
-
```python
|
|
82
|
-
# Gregorian datetime
|
|
83
|
-
datetime.datetime.now()
|
|
84
|
-
|
|
85
|
-
# Bikram Sambat datetime
|
|
86
|
-
npdatetime.datetime.now()
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### **Creating Date and Datetime Objects**
|
|
90
|
-
```python
|
|
91
|
-
# Gregorian date
|
|
92
|
-
datetime.date(2020, 9, 4)
|
|
93
|
-
|
|
94
|
-
# Bikram Sambat date
|
|
95
|
-
npdatetime.date(2077, 5, 19)
|
|
96
|
-
|
|
97
|
-
# Gregorian datetime
|
|
98
|
-
datetime.datetime(2020, 9, 4, 8, 26, 10, 123456)
|
|
99
|
-
|
|
100
|
-
# Bikram Sambat datetime
|
|
101
|
-
npdatetime.datetime(2077, 5, 19, 8, 26, 10, 123456)
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### **Date/Datetime Formatting**
|
|
105
|
-
```python
|
|
106
|
-
# Formatting Bikram Sambat date
|
|
107
|
-
npdatetime.datetime(2077, 5, 19, 8, 26, 10, 123456).strftime("%d %B %Y")
|
|
108
|
-
# Output: 19 Bhadau 2077
|
|
109
|
-
|
|
110
|
-
# Formatting with Nepali Unicode
|
|
111
|
-
npdatetime.date(1977, 10, 25).strftime('%K-%n-%D (%k %N %G)')
|
|
112
|
-
# Output: १९७७-१०-२५ (७७ माघ आइतबार)
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### **Parsing from String**
|
|
116
|
-
```python
|
|
117
|
-
npdatetime.datetime.strptime('2077-09-12', '%Y-%m-%d')
|
|
118
|
-
# Output: npdatetime.datetime(2077, 9, 12, 0, 0)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### **Timedelta Operations**
|
|
122
|
-
```python
|
|
123
|
-
# Adding days to a date
|
|
124
|
-
npdatetime.date(1990, 5, 10) + datetime.timedelta(days=350)
|
|
125
|
-
# Output: npdatetime.date(1991, 4, 26)
|
|
126
|
-
|
|
127
|
-
# Adding hours and minutes to a datetime
|
|
128
|
-
npdatetime.datetime(1990, 5, 10, 5, 10, 20) + datetime.timedelta(hours=3, minutes=15)
|
|
129
|
-
# Output: npdatetime.datetime(1990, 5, 10, 8, 25, 20)
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### **Bikram Sambat <-> Gregorian Conversion**
|
|
133
|
-
```python
|
|
134
|
-
# Convert Bikram Sambat to Gregorian
|
|
135
|
-
npdatetime.date(1999, 7, 25).to_datetime_date()
|
|
136
|
-
# Output: datetime.date(1942, 11, 10)
|
|
137
|
-
|
|
138
|
-
# Convert Gregorian to Bikram Sambat
|
|
139
|
-
npdatetime.date.from_datetime_date(datetime.date(1942, 11, 10))
|
|
140
|
-
# Output: npdatetime.date(1999, 7, 25)
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### **Bikram Sambat Monthly Calendar**
|
|
144
|
-
```python
|
|
145
|
-
npdatetime.date(2078, 1, 1).calendar()
|
|
146
|
-
|
|
147
|
-
# Output:
|
|
148
|
-
Baishakh 2078
|
|
149
|
-
Sun Mon Tue Wed Thu Fri Sat
|
|
150
|
-
1 2 3 4
|
|
151
|
-
5 6 7 8 9 10 11
|
|
152
|
-
12 13 14 15 16 17 18
|
|
153
|
-
19 20 21 22 23 24 25
|
|
154
|
-
26 27 28 29 30 31
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## **Documentation**
|
|
160
|
-
|
|
161
|
-
Comprehensive usage and examples can be found in the [official documentation](https://4mritGiri.github.io/npdatetime/).
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## **Contribution**
|
|
166
|
-
|
|
167
|
-
Contributions are highly encouraged!
|
|
168
|
-
Refer to the [CONTRIBUTING.md](https://github.com/4mritGiri/npdatetime/blob/master/CONTRIBUTING.md) guide for details on how to get started.
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## **License**
|
|
173
|
-
|
|
174
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## **Feedback & Support**
|
|
179
|
-
|
|
180
|
-
For feature requests, bugs, or feedback, please raise an issue on [GitHub](https://github.com/4mritGiri/npdatetime/issues).
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
npdatetime/__init__.py,sha256=4-arrqG1kVK_MBCikeD2gDWpTWsLwm7CRRe2rKzBubg,37958
|
|
2
|
-
npdatetime/__init__.pyi,sha256=JOPIVFiqz6eoxNpPGO9LETNLLf_YPJL5wnvmLN3eq9U,10106
|
|
3
|
-
npdatetime/_custom_strptime.py,sha256=sO1CkAJV_4Ahgr0cqJjc4HncihVt0S0KzoKIblDYZMw,12014
|
|
4
|
-
npdatetime/config.py,sha256=C-ozgMViZyhbIUtP1phZ-xshktPwdbsVssFUTYVP6Os,396
|
|
5
|
-
npdatetime/data/calendar_bs.csv,sha256=G9KWbb35Ietcz31K2E4R5J2a5rhQl0QJjw1TA_V4M8s,5250
|
|
6
|
-
npdatetime-0.1.1.dist-info/LICENSE,sha256=zVhPTICUPJU67BU1DoMb0SofU9Zo2uY1kV-jn2SqvfI,1082
|
|
7
|
-
npdatetime-0.1.1.dist-info/METADATA,sha256=2fMu2a40xjDDX-uTMTDeNNlHFqJCBU9XrHs1HovupGo,5828
|
|
8
|
-
npdatetime-0.1.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
9
|
-
npdatetime-0.1.1.dist-info/top_level.txt,sha256=2FR7RutVmSD6SL-iOwUcGrHd1XXgzaqUvAU78WGz_9g,11
|
|
10
|
-
npdatetime-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|