nepali 0.5.5__py3-none-any.whl → 1.2.0__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.
Files changed (51) hide show
  1. nepali/__init__.py +1 -1
  2. nepali/char.py +102 -81
  3. nepali/constants.py +66 -0
  4. nepali/date_converter.py +334 -0
  5. nepali/datetime/__init__.py +13 -14
  6. nepali/datetime/_datetime.py +391 -402
  7. nepali/datetime/_formatter.py +325 -0
  8. nepali/datetime/_humanize.py +117 -132
  9. nepali/datetime/_nepalimonth.py +118 -0
  10. nepali/datetime/_nepaliweek.py +125 -0
  11. nepali/datetime/parser/__init__.py +4 -4
  12. nepali/datetime/parser/_parser.py +59 -50
  13. nepali/datetime/parser/validators.py +249 -159
  14. nepali/datetime/utils.py +38 -0
  15. nepali/exceptions.py +8 -3
  16. nepali/locations/__init__.py +3 -0
  17. nepali/locations/_data.py +4271 -0
  18. nepali/locations/_locations.py +38 -0
  19. nepali/locations/models.py +104 -0
  20. nepali/locations/utils.py +54 -0
  21. nepali/number/__init__.py +19 -0
  22. nepali/number/_nepalinumber.py +563 -0
  23. nepali/number/_number.py +53 -0
  24. nepali/number/utils.py +72 -0
  25. nepali/phone_number.py +183 -0
  26. nepali/templatetags/__init__.py +0 -0
  27. nepali/templatetags/nepalidatetime.py +194 -24
  28. nepali/templatetags/nepalinumber.py +97 -7
  29. nepali/tests/test_date_converter.py +148 -0
  30. nepali/tests/test_datetime.py +275 -29
  31. nepali/tests/test_humanize.py +78 -7
  32. nepali/tests/test_locations.py +154 -0
  33. nepali/tests/test_nepalimonth.py +152 -0
  34. nepali/tests/test_nepaliweek.py +154 -0
  35. nepali/tests/test_number.py +3152 -0
  36. nepali/tests/test_parser.py +82 -69
  37. nepali/tests/test_phone_number.py +254 -0
  38. nepali/tests/test_timezone.py +192 -0
  39. nepali/timezone.py +50 -7
  40. nepali/utils.py +9 -68
  41. nepali-1.2.0.dist-info/METADATA +476 -0
  42. nepali-1.2.0.dist-info/RECORD +46 -0
  43. {nepali-0.5.5.dist-info → nepali-1.2.0.dist-info}/WHEEL +1 -1
  44. {nepali-0.5.5.dist-info → nepali-1.2.0.dist-info/licenses}/LICENSE +1 -1
  45. {nepali-0.5.5.dist-info → nepali-1.2.0.dist-info}/top_level.txt +0 -0
  46. nepali/datetime/_converter.py +0 -394
  47. nepali/datetime/_formarter.py +0 -314
  48. nepali/datetime.py +0 -1169
  49. nepali/number.py +0 -51
  50. nepali-0.5.5.dist-info/METADATA +0 -220
  51. nepali-0.5.5.dist-info/RECORD +0 -27
nepali/timezone.py CHANGED
@@ -1,24 +1,67 @@
1
1
  import datetime
2
2
 
3
+ from .constants import NEPAL_TIMEZONE
4
+
5
+
3
6
  class NepaliTimeZone(datetime.tzinfo):
7
+ """
8
+ NepaliTimeZone: "Asia/Kathmandu", +05:45
9
+ """
10
+
4
11
  def utcoffset(self, dt):
5
12
  return self.dst(dt) + datetime.timedelta(hours=5, minutes=45)
6
13
 
7
14
  def dst(self, dt):
8
15
  return datetime.timedelta(0)
9
-
10
- def tzname(self,dt):
11
- return "Asia/Kathmandu"
16
+
17
+ def tzname(self, dt):
18
+ return NEPAL_TIMEZONE
12
19
 
13
20
  def __str__(self):
14
- return "Asia/Kathmandu"
21
+ return NEPAL_TIMEZONE
22
+
23
+ def __repr__(self):
24
+ return NEPAL_TIMEZONE
25
+
26
+ def __eq__(self, o: object) -> bool:
27
+ return isinstance(o, self.__class__)
28
+
15
29
 
16
- def get_timezone():
30
+ def get_timezone() -> datetime.tzinfo | None:
31
+ """
32
+ Returns current device's timezone.
33
+ Timezone of the machine.
34
+ """
17
35
  return datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
18
36
 
19
- def now():
37
+
38
+ def now() -> datetime.datetime:
39
+ """Returns current datetime object of the device"""
20
40
  return datetime.datetime.now(get_timezone())
21
41
 
22
- def utc_now():
42
+
43
+ def utc_now() -> datetime.datetime:
44
+ """Returns UTC time datetime object"""
23
45
  return datetime.datetime.now(datetime.timezone.utc)
24
46
 
47
+
48
+ def to_utc_timezone(datetime_obj: datetime.datetime) -> datetime.datetime:
49
+ """Changes the timezone of the given datetime object to UTC."""
50
+ if type(datetime_obj) != datetime.datetime:
51
+ # Not a datetime object
52
+ return datetime_obj
53
+
54
+ if not hasattr(datetime_obj, "tzinfo") or not datetime_obj.tzinfo:
55
+ datetime_obj = datetime_obj.replace(tzinfo=get_timezone())
56
+ return datetime_obj.astimezone(datetime.timezone.utc)
57
+
58
+
59
+ def to_nepali_timezone(datetime_obj: datetime.datetime) -> datetime.datetime:
60
+ """Changes the timezone of the given datetime object to NepaliTimeZone."""
61
+ if type(datetime_obj) != datetime.datetime:
62
+ # Not a datetime object
63
+ return datetime_obj
64
+
65
+ if not hasattr(datetime_obj, "tzinfo") or not datetime_obj.tzinfo:
66
+ datetime_obj = datetime_obj.replace(tzinfo=get_timezone())
67
+ return datetime_obj.astimezone(NepaliTimeZone())
nepali/utils.py CHANGED
@@ -1,68 +1,9 @@
1
- import datetime
2
- import pytz
3
- import warnings
4
-
5
- from .timezone import NepaliTimeZone, get_timezone
6
- from .exceptions import InvalidNepaliDateTimeObjectException
7
-
8
- def to_utc_timezone(datetime_obj):
9
- if type(datetime_obj) != datetime.datetime:
10
- # None datetime object
11
- return datetime_obj
12
-
13
- if (not hasattr(datetime_obj, 'tzinfo')) or (not datetime_obj.tzinfo):
14
- datetime_obj = datetime_obj.replace(tzinfo=get_timezone())
15
- return datetime_obj.astimezone(pytz.timezone('UTC'))
16
-
17
- def to_utc(datetime_obj):
18
- warnings.warn(
19
- message="to_utc is depreciated and no longer be available in version >= 1.0.0, use to_utc_timezone instead.",
20
- category=DeprecationWarning
21
- )
22
- return to_utc_timezone(datetime_obj)
23
-
24
- def to_nepali_timezone(datetime_obj):
25
- if type(datetime_obj) != datetime.datetime:
26
- return datetime_obj
27
-
28
- if (not hasattr(datetime_obj, 'tzinfo')) or (not datetime_obj.tzinfo):
29
- datetime_obj = datetime_obj.replace(tzinfo=get_timezone())
30
- return datetime_obj.astimezone(NepaliTimeZone())
31
-
32
- def to_local(datetime_obj):
33
- warnings.warn(
34
- message="to_local is depreciated and no longer be available in version >= 1.0.0, use to_nepali_timezone instead.",
35
- category=DeprecationWarning
36
- )
37
- return to_nepali_timezone(datetime_obj)
38
-
39
- def to_nepalidatetime(datetime_object):
40
- """
41
- Converts nepalidate, datetime.datetime, datetime.date to nepalidatetime.
42
- """
43
- from .datetime import nepalidate, nepalidatetime
44
-
45
- if type(datetime_object) == nepalidatetime:
46
- return datetime_object
47
- elif type(datetime_object) == nepalidate:
48
- return nepalidatetime.from_nepali_date(datetime_object)
49
- elif type(datetime_object) == datetime.datetime:
50
- return nepalidatetime.from_datetime(datetime_object)
51
- elif type(datetime_object) == datetime.date:
52
- return nepalidatetime.from_date(datetime_object)
53
- elif datetime_object == '' or datetime_object == None:
54
- return None
55
- raise InvalidNepaliDateTimeObjectException('Argument must be instance of nepalidate or nepalidatetime or datetime.datetime or datetime.date')
56
-
57
- def to_nepali_datetime(datetime_object):
58
- warnings.warn(
59
- message="to_nepali_datetime is depreciated and no longer be available in version >= 1.0.0, use to_nepalidatetime instead.",
60
- category=DeprecationWarning
61
- )
62
- return to_nepalidatetime(datetime_object)
63
-
64
- def to_nepalidate(datetime_object):
65
- nepalidatetime_obj = to_nepalidatetime(datetime_object)
66
- if nepalidatetime_obj != None:
67
- return nepalidatetime_obj.date()
68
- return
1
+ from nepali.datetime.utils import to_nepalidate, to_nepalidatetime
2
+ from nepali.timezone import to_nepali_timezone, to_utc_timezone
3
+
4
+ __all__ = [
5
+ "to_nepalidate",
6
+ "to_nepalidatetime",
7
+ "to_utc_timezone",
8
+ "to_nepali_timezone",
9
+ ]
@@ -0,0 +1,476 @@
1
+ Metadata-Version: 2.4
2
+ Name: nepali
3
+ Version: 1.2.0
4
+ Summary: nepalidatetime compatible with python's datetime feature. Converting nepali date to english, parsing nepali datetime, nepali timezone, and timedelta support in nepali datetime
5
+ Home-page: https://github.com/opensource-nepal/py-nepali
6
+ Author: opensource-nepal
7
+ Author-email: aj3sshh@gmail.com, sugatbajracharya49@gmail.com
8
+ License: MIT
9
+ Project-URL: Source, https://github.com/opensource-nepal/py-nepali
10
+ Project-URL: Changelog, https://github.com/opensource-nepal/py-nepali/blob/main/CHANGELOG.md
11
+ Keywords: nepali date conversion,convert date,nepali date time,python convert date,parse nepali date time
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license
30
+ Dynamic: license-file
31
+ Dynamic: project-url
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # nepali
36
+
37
+ [![PyPI version](https://badge.fury.io/py/nepali.svg)](https://badge.fury.io/py/nepali)
38
+ [![CI status](https://github.com/opensource-nepal/py-nepali/actions/workflows/python-package.yml/badge.svg?branch=main)](https://github.com/opensource-nepal/py-nepali/actions)
39
+ [![Downloads](https://img.shields.io/pypi/dm/nepali.svg?maxAge=180)](https://pypi.org/project/nepali/)
40
+ [![codecov](https://codecov.io/gh/opensource-nepal/py-nepali/branch/main/graph/badge.svg?token=PTUHYWCJ4I)](https://codecov.io/gh/opensource-nepal/py-nepali)
41
+
42
+ `nepali` is a python package containing features that will be useful for Nepali projects.
43
+
44
+ The major feature of this package is nepalidatetime, which is compatible with python's datetime feature. It helps nepali date to english, parsing nepali datetime, nepali timezone, and timedelta support in nepali datetime.
45
+
46
+ ## Example
47
+
48
+ ```python
49
+ import datetime
50
+ from nepali import phone_number
51
+ from nepali.datetime import nepalidate, parser
52
+
53
+ nepali_datetime = parser.parse('2079-02-15')
54
+ # 2079-02-15 00:00:00
55
+
56
+ date = datetime.date(2017, 3, 15)
57
+ nepali_date = nepalidate.from_date(date)
58
+ # 2073-12-02
59
+
60
+ phone_number.parse("+977-9845217789")
61
+ # {
62
+ # 'type': 'Mobile',
63
+ # 'number': '9845217789',
64
+ # 'operator': <Operator: Nepal Telecom>
65
+ # }
66
+ ```
67
+
68
+ ## Requirements
69
+
70
+ Python >= 3.10
71
+
72
+ ## Installation
73
+
74
+ pip install nepali
75
+
76
+ ## Features
77
+
78
+ 1. [Date and Time](#date-and-time)
79
+ - [date_converter](#date_converter)
80
+ - [nepalidate](#nepalidate)
81
+ - [nepalidatetime](#nepalidatetime)
82
+ - [nepalihumanize](#nepalihumanize)
83
+ - [timezone](#timezone)
84
+ - [parse](#parse)
85
+ - [strftime() and strptime() Format Codes](#strftime-and-strptime-format-codes)
86
+ 1. [Numbers](#numbers)
87
+ - [nepalinumber](#nepalinumber)
88
+ 1. [Phone Number](#phone-number)
89
+ 1. [Locations](#locations)
90
+ 1. [For Django Template](#for-django-template)
91
+
92
+ ## Date and Time
93
+
94
+ ### date_converter
95
+
96
+ Date converter module converts english date to nepali and nepali date to english. It doesn't contain any extra functionality.
97
+
98
+ **Convert English date to Nepali date**
99
+
100
+ ```python
101
+ from nepali.date_converter import converter
102
+
103
+ np_year, np_month, np_date = converter.english_to_nepali(en_year, en_month, en_date)
104
+ ```
105
+
106
+ Example
107
+
108
+ ```python
109
+ from nepali.date_converter import converter
110
+
111
+ np_year, np_month, np_date = converter.english_to_nepali(2023, 2, 7)
112
+ print(np_year, np_month, np_date) # 2079 10 24
113
+ ```
114
+
115
+ **Convert Nepali date to English date**
116
+
117
+ ```python
118
+ from nepali.date_converter import converter
119
+
120
+ en_year, en_month, en_date = converter.nepali_to_english(np_year, np_month, np_date)
121
+ ```
122
+
123
+ Example
124
+
125
+ ```python
126
+ from nepali.date_converter import converter
127
+
128
+ en_year, en_month, en_date = converter.nepali_to_english(2079, 10, 24)
129
+ print(en_year, en_month, en_date) # 2023 2 7
130
+ ```
131
+
132
+ ### nepalidate
133
+
134
+ **Creating a new nepalidate object**
135
+
136
+ ```python
137
+ from nepali.datetime import nepalidate
138
+
139
+ # nepalidate object with year, month, day
140
+ np_date = nepalidate(year, month, day)
141
+
142
+ # nepalidate object with today's date
143
+ np_date = nepalidate.today()
144
+
145
+ # parse nepali date
146
+ np_date = nepalidate.strptime('2078-01-18', format='%Y-%m-%d')
147
+ ```
148
+
149
+ **Getting nepalidate object from python datetime**
150
+
151
+ ```python
152
+ # from date object
153
+ np_date = nepalidate.from_date(date_obj)
154
+
155
+ # from datetime object
156
+ np_date = nepalidate.from_datetime(datetime_obj)
157
+ ```
158
+
159
+ **Attributes and Methods**
160
+
161
+ ```python
162
+ np_date.year # 2078 (year)
163
+ np_date.month # 1 (month)
164
+ np_date.day # 18 (day)
165
+
166
+ np_date.to_date() # datetime.date object
167
+ np_date.to_datetime() # datetime.datetime object
168
+ np_date.to_nepalidatetime() # nepalidatetime object
169
+
170
+ np_date.strftime("%Y-%m-%d") # 2078-01-18
171
+ np_date.strftime_ne("%Y-%m-%d") # २०७८-०१-१८
172
+
173
+ np_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6
174
+ ```
175
+
176
+ ### nepalidatetime
177
+
178
+ **Creating a new nepalidatetime object**
179
+
180
+ ```python
181
+ from nepali.datetime import nepalidatetime
182
+
183
+ # nepalidate object with year, month, day, hour, minute, second
184
+ np_datetime = nepalidatetime(year, month, day[, hour[, minute[, second]]])
185
+
186
+ # nepalidate object with current date and time
187
+ np_datetime = nepalidate.now()
188
+ np_datetime = nepalidate.today()
189
+
190
+ # parse nepali datetime
191
+ np_datetime = nepalidatetime.strptime('2078-01-12 13:12', format='%Y-%m-%d %H:%M')
192
+ ```
193
+
194
+ **Getting nepalidatetime object from python datetime**
195
+
196
+ ```python
197
+ # from date object
198
+ np_datetime = nepalidatetime.from_date(date_obj)
199
+
200
+ # from datetime object
201
+ np_datetime = nepalidatetime.from_datetime(datetime_obj)
202
+ ```
203
+
204
+ **Getting nepalidatetime object from nepalidate**
205
+
206
+ ```python
207
+ np_datetime = nepalidatetime.from_nepalidate(nepali_date)
208
+ ```
209
+
210
+ **Attributes and Methods**
211
+
212
+ ```python
213
+ np_date.year # 2078 (year)
214
+ np_date.month # 1 (month)
215
+ np_date.day # 18 (day)
216
+ np_date.hour # 23 (hour)
217
+ np_date.minute # 59 (minute)
218
+ np_date.second # 59 (day)
219
+
220
+ np_date.to_date() # datetime.date object
221
+ np_date.to_datetime() # datetime.datetime object
222
+ np_date.to_nepalidate() # nepalidatetime object
223
+ np_date.to_time() # nepalitime object (datetime.time compatible)
224
+
225
+ np_date.strftime("%Y-%m-%d %H:%M") # 2078-01-18 23:59
226
+ np_date.strftime_ne("%Y-%m-%d %H:%M") # २०७८-०१-१८ २३:५९
227
+
228
+ np_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6
229
+ ```
230
+
231
+ **Timedelta support**
232
+
233
+ ```python
234
+ # timedelta addition and subtraction
235
+ np_datetime - datetime.timedelta(days=3) # returns nepalidatetime
236
+
237
+ # comparison between two dates
238
+ np_datetime1 - np_datetime2 # returns timedelta object
239
+ np_datetime1 < np_datetime2 # returns bool (True/False)
240
+ np_datetime1 >= datetime.datetime.now() # returns bool (True/False)
241
+ ...
242
+ ```
243
+
244
+ ### nepalihumanize
245
+
246
+ Returns readable form of nepali date.
247
+
248
+ ```python
249
+ from nepali.datetime import nepalihumanize
250
+
251
+
252
+ nepalihumanize(datetime, [threshold, format])
253
+ ```
254
+
255
+ The `threshold` is and optional field and is in seconds and the format is for the `strftime` format. If the datetime object crosses the threshold it print the date with the format. The `format` is also an optional and is `%B %d, %Y` in default.
256
+
257
+ Example
258
+
259
+ ```python
260
+ from nepali.datetime import nepalihumanize, nepalidatetime
261
+
262
+ np_datetime = nepalidatetime(2079, 10, 5)
263
+ output = nepalihumanize(np_datetime)
264
+ # output: ३ महिना अघि
265
+
266
+ output = nepalihumanize(np_datetime, threshold=1400)
267
+ # 1400 = 2 * 30 * 24; two months threshold
268
+ # output: माघ ०५, २०७९
269
+ ```
270
+
271
+ ### timezone
272
+
273
+ **NepaliTimeZone**
274
+ You can use `NepaliTimeZone` directly to your datetime object.
275
+
276
+ ```python
277
+ from nepali.timezone import NepaliTimeZone
278
+
279
+ datetime.datetime(2018, 8, 12, 16, 23, tzinfo=NepaliTimeZone())
280
+ ```
281
+
282
+ **now**
283
+ Returns current datetime object with timezone
284
+
285
+ ```python
286
+ from nepali import timezone
287
+
288
+ timezone.now()
289
+ ```
290
+
291
+ `datetime.now()` vs `timezone.now()`:
292
+ `datetime.now()` doesn't contain timezone, but `timezone.now()` will contain timezone of the system.
293
+
294
+ **utc_now**
295
+ Returns current UTC datetime object (with timezone UTC)
296
+
297
+ ```python
298
+ from nepali import timezone
299
+
300
+ timezone.utc_now()
301
+ ```
302
+
303
+ ### parse
304
+
305
+ Parses date with commonly used date formats. Auto detects date format. If you are sure about the format, please use `strptime`.
306
+
307
+ ```python
308
+ from nepali.datetime.parser import parse
309
+
310
+ np_datetime = parse(datetime_str)
311
+ ```
312
+
313
+ Example
314
+
315
+ ```python
316
+ np_datetime = parse("2079-02-15") # 2079-02-15 00:00:00
317
+ np_datetime = parse("२०७८-०१-१८") # 2078-01-15 00:00:00
318
+ np_datetime = parse("2079/02/15") # 2079-02-15 00:00:00
319
+ np_datetime = parse("2079-02-15 15:23") # 2079-02-15 15:23:00
320
+ np_datetime = parse("2079-02-15 5:23 AM") # 2079-02-15 05:23:00
321
+ np_datetime = parse("2079-02-15 5:23 AM") # 2079-02-15 05:23:00
322
+ np_datetime = parse("Jestha 15, 2079") # 2079-02-15 00:00:00
323
+
324
+ ```
325
+
326
+ ### strftime() and strptime() Format Codes
327
+
328
+ | Directive | Meaning | Example |
329
+ | --------- | --------------------------------------------------------- | ------------------------------ |
330
+ | `%a` | Weekday as locale’s abbreviated name. | Sun, Mon, …, Sat (आइत, सोम, …) |
331
+ | `%A` | Weekday as locale’s full name. | Sunday, Monday, …, Saturday |
332
+ | `%d` | Day of the month as a zero-padded decimal number. | 01, 02, …, 31 |
333
+ | `%-d` | Day of the month as a decimal number. | 1, 2, …, 31 |
334
+ | `%B` | Month as locale’s full name. | Baishakh, Jestha, …, Chaitra |
335
+ | `%m` | Month as a zero-padded decimal number. | 01, 02, …, 12 |
336
+ | `%-m` | Month as a decimal number. | 1, 2, …, 12 |
337
+ | `%y` | Year without century as a zero-padded decimal number. | 00, 01, …, 99 |
338
+ | `%Y` | Year with century as a decimal number. | 2001, 2078, 2079, …, 2099 |
339
+ | `%H` | Hour (24-hour clock) as a zero-padded decimal number. | 00, 01, …, 23 |
340
+ | `%-H` | Hour (24-hour clock) as a decimal number. | 0, 1, 2, …, 23 |
341
+ | `%I` | Hour (12-hour clock) as a zero-padded decimal number. | 01, 02, …, 12 |
342
+ | `%-I` | Hour (12-hour clock) as a decimal number. | 1, 2, …, 12 |
343
+ | `%p` | Locale’s equivalent of either AM or PM. | AM, PM (en_US) |
344
+ | `%M` | Minute as a zero-padded decimal number. | 00, 01, …, 59 |
345
+ | `%-M` | Minute as a decimal number. | 0, 1, 2, …, 59 |
346
+ | `%S` | Second as a zero-padded decimal number. | 00, 01, …, 59 |
347
+ | `%-S` | Second as a decimal number. | 0, 1, 2, …, 59 |
348
+ | `%f` | Microsecond as a decimal number, zero-padded to 6 digits. | 000000, 000001, …, 999999 |
349
+ | `%%` | A literal `'%'` character. | % |
350
+
351
+ ---
352
+
353
+ ## Numbers
354
+
355
+ ```python
356
+ from nepali import number
357
+ ```
358
+
359
+ **convert**
360
+ Converts english number to nepali.
361
+
362
+ ```python
363
+ np_number = number.convert("1234567890") # १२३४५६७८९०
364
+ ```
365
+
366
+ **revert**
367
+ Converts english number to nepali.
368
+
369
+ ```python
370
+ en_number = number.revert("१२३४५६७८९०") # 1234567890
371
+ ```
372
+
373
+ **add_comma**
374
+ Adds comma in nepali numbers.
375
+
376
+ ```python
377
+ number_text = number.add_comma("1234567890") # 1,23,45,67,890
378
+ ```
379
+
380
+ ### nepalinumber
381
+ `nepalinumber` is a new data type, which can be used to represent Nepali (Devanagari) numbers. It allows us to perform arithmetic operations, just like with int and float. Additionally, it can be used to parse numbers and output them in Devanagari format.
382
+
383
+ ```python
384
+ from nepali.number import nepalinumber
385
+ ```
386
+
387
+ **Parsing**
388
+ ```python
389
+ a = nepalinumber("१८.२७")
390
+ print(a) # 18.27
391
+
392
+ b = nepalinumber(15)
393
+ print(b) # 15
394
+ ```
395
+
396
+ **Nepali (Devanagari) output**
397
+ ```python
398
+ a = nepalinumber("18.27")
399
+ print(a.str_ne()) # १८.२७
400
+ ```
401
+
402
+ **Arithmetic operations**
403
+ ```python
404
+ a = nepalinumber("1")
405
+ b = nepalinumber("२")
406
+ c = a + b * 3
407
+ print(c) # 7
408
+ ```
409
+ ---
410
+
411
+ ## Phone Number
412
+
413
+ ```python
414
+ from nepali import phone_number
415
+ ```
416
+
417
+ **is_valid**
418
+ Checks is the given number is a valid nepali phone number.
419
+
420
+ ```python
421
+ phone_number.is_valid("9851377890") # True
422
+ phone_number.is_valid("+977-142314819") # True
423
+
424
+ phone_number.is_valid("8251377890") # False
425
+ ```
426
+
427
+ **parse**
428
+ Parse phone number and returns details of the number.
429
+
430
+ ```python
431
+ phone_number.parse("9851377890")
432
+ # {'type': 'Mobile', 'number': '9851377890', 'operator': <Operator: Nepal Telecom>}
433
+
434
+ phone_number.parse("+977-142314819")
435
+ # {'type': 'Landline', 'number': '0142314819', 'area_code': '01'}
436
+ ```
437
+
438
+ ---
439
+
440
+ ## Locations
441
+
442
+ Provides details of Nepal's Province, District, and Municipality.
443
+
444
+ ```python
445
+ from nepali.locations import provinces, districts, municipalities
446
+ ```
447
+
448
+ ```python
449
+ from nepali.locations.utils import get_province, get_district, get_municipality
450
+
451
+ # Province
452
+ get_province(name="Bagmati")
453
+ # Bagmati Province
454
+
455
+ # District
456
+ get_district(name="Kathmandu")
457
+ # Kathmandu
458
+
459
+ # Municipality
460
+ get_municipality(name="Kathmandu")
461
+ # Kathmandu Metropolitan City
462
+
463
+ # Municipality
464
+ get_municipality(name_nepali="विराटनगर")
465
+ # Biratnagar Metropolitan City
466
+ ```
467
+
468
+ ---
469
+
470
+ ## For Django
471
+
472
+ We have created a new Django package called [django-nepali](https://github.com/opensource-nepal/django-nepali) to support `nepali` package. For more information, please visit [django-nepali](https://github.com/opensource-nepal/django-nepali).
473
+
474
+ ## Contribution
475
+
476
+ We appreciate feedback and contribution to this package. To get started please see our [contribution guide](./CONTRIBUTING.md)
@@ -0,0 +1,46 @@
1
+ nepali/__init__.py,sha256=8Vx8S0r8UT5PoFdlGHBp59j84si87m4mWgGipzwhVvs,16
2
+ nepali/char.py,sha256=WglBe0AefpsHwIXaPXr0FVjdI4qvmr06U8kSQLtvjdQ,3437
3
+ nepali/constants.py,sha256=FA5qvFaiNKyQ5APQytDovbr9tBPIITgLpPMrR0UlbsY,1309
4
+ nepali/date_converter.py,sha256=9LX3QLGrZUxbF52oQLLhSk2Wv8LKQqZhfdo6T_LUK_4,13591
5
+ nepali/exceptions.py,sha256=CKg1wEUuzcog7w8Q7pGBNthi9oTOeg_3Aapx1WaTveY,329
6
+ nepali/phone_number.py,sha256=bsmvIgTPZEOBXzWWN1Uu2I2WsFEr-tNCVwZOZi3S2tQ,4141
7
+ nepali/timezone.py,sha256=Sm8Vmd9UwpPA0VNzcnjnIodkdvkzU-5ZQwW3b7RmYI4,1964
8
+ nepali/utils.py,sha256=rOHuHuUZzcTCQTfFXn3RneS9lx9RbtDTifnkO-buoDc,241
9
+ nepali/datetime/__init__.py,sha256=5tfqVCXri3zACb2twLI1QcYw9wp4-Omj6tJhSny-mxo,427
10
+ nepali/datetime/_datetime.py,sha256=jIeSotLQ_rLe5keRGZt31usDIt0RiXuM4SsPkbxmFsI,12049
11
+ nepali/datetime/_formatter.py,sha256=U0Fe-mPwM25VSru124SRG9Olv0FD1WwaFjR22G9TuOU,8744
12
+ nepali/datetime/_humanize.py,sha256=mfucIbpdZqq2-GjolfhLUP22dKkmy7484hE1FpzHvnM,3636
13
+ nepali/datetime/_nepalimonth.py,sha256=lSKvtS5q_WO0ImDEZgNAhZ9PkwbqfH_3f35qNKpX9uA,3224
14
+ nepali/datetime/_nepaliweek.py,sha256=rlCUlqkfN3IM6SsVmk0sbjA5ZxcYqC_Juw0uzFovJFQ,3400
15
+ nepali/datetime/utils.py,sha256=UpBhiwRrNg8bpTW018_gSzk3w8BMZiqVcK0C3x16JYU,1482
16
+ nepali/datetime/parser/__init__.py,sha256=IXGIIG8KO3VP4BPPQegoz2LRven1L9pLkM0mYbvHf7I,81
17
+ nepali/datetime/parser/_parser.py,sha256=U7W3wrY5hAPoB9XMD5KMT8OCEy6ZyIF48UHXnJRfny0,1930
18
+ nepali/datetime/parser/validators.py,sha256=6BkYsfVLVzYdDCDJALtfm3cKaFmzE0_esp8C7t_WXYk,10592
19
+ nepali/locations/__init__.py,sha256=kaBcuMBHrf38Zj7BTXRIwP6rdXnzc_bpQMcig8BzDcQ,117
20
+ nepali/locations/_data.py,sha256=W_fC9bImDSAY50JU5nQZ0zWHcIUNo4tJjukiHW2I538,216499
21
+ nepali/locations/_locations.py,sha256=6Io5YkBAKHNPSFarvfeV7ZDDRACCMQvJ0oEyaMDM4hg,1316
22
+ nepali/locations/models.py,sha256=UDPJNX5DgyFr9HPJYks1fNEpVtRK6zOpwTcI04cGXcg,2846
23
+ nepali/locations/utils.py,sha256=dPV8tJDTajgfJaQ6qNMgnemMTlilYzza0m6DhrxkdOs,1546
24
+ nepali/number/__init__.py,sha256=r1qwwG-HQ_QtMt_qvfBZMmBKgWQArBERYRs4tJdFjKY,384
25
+ nepali/number/_nepalinumber.py,sha256=0BnU43cMHSM9ntxo3w3dvNmGRTAjnyJdicvFPdJgyB4,19393
26
+ nepali/number/_number.py,sha256=qPqXSeU7YxIR1IXxjgmfFeIlCWre8_6IHtPD_0ip20I,1892
27
+ nepali/number/utils.py,sha256=ieGpY0DK5_FZaTvSKp8q4hMepjWqyXtGtf7T7-0iVp4,1878
28
+ nepali/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ nepali/templatetags/nepalidatetime.py,sha256=g6UtfkToZtVDVe_Z9aGPwYPhNrPpZzvfi1bzFdTjSpg,5789
30
+ nepali/templatetags/nepalinumber.py,sha256=hjq0cxI1o_uny_8aH9skUhqzhWi4YvnvY3ivdt1ulGU,2452
31
+ nepali/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ nepali/tests/test_date_converter.py,sha256=9Ubr_SytLIIj-ptF7vhbQVjOEZQ2PVauXj6E4utYIHw,5830
33
+ nepali/tests/test_datetime.py,sha256=YjXGxnqeu4ytn5HpDU4CxwYTNmiB-KilJv10T2Wc5Eo,13581
34
+ nepali/tests/test_humanize.py,sha256=DX0-I1aXZkBNSPtXKbRrIPiBVxzVaFRItlDwx4lDzko,3845
35
+ nepali/tests/test_locations.py,sha256=DoiqiLh8FdvervTyqbbeG-f7QQDTOiQ4GJS68OheNPs,5968
36
+ nepali/tests/test_nepalimonth.py,sha256=1e-nFpCvk_JGUhRtjAL9_NDck2Ue828Gp3sN_uAWGxU,6575
37
+ nepali/tests/test_nepaliweek.py,sha256=ycGE3gY1d6JjF0VyAy5DbVGg3ayLcRTwAHruSqAWF_4,6468
38
+ nepali/tests/test_number.py,sha256=2jBadNFrslbvW0fjVGvRTe-0eVeFy8bVEX6ucOuG4Z4,119021
39
+ nepali/tests/test_parser.py,sha256=_p6H09Ybw-sTRpNNgf7qMibEtnubI-HRECxrbLlgRnw,6712
40
+ nepali/tests/test_phone_number.py,sha256=fswHlwgaiS3outmHOevNj1IVh0ZOYyrvuFKYBYODGRE,11726
41
+ nepali/tests/test_timezone.py,sha256=-GBtiRU5msL9SjPeBBrZuXKMn89k_Q4mqhiT48W0BJE,6542
42
+ nepali-1.2.0.dist-info/licenses/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
43
+ nepali-1.2.0.dist-info/METADATA,sha256=lg-DgODmR2CFvXJtv3gJwtIIerZ1jf6hbak_x-2QUxY,14639
44
+ nepali-1.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
45
+ nepali-1.2.0.dist-info/top_level.txt,sha256=joX2GOfHg0KHYsDxi7eXDVTBQK0t6ZsvKz9uz7S6mFE,7
46
+ nepali-1.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
16
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
19
+ SOFTWARE.