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/number.py DELETED
@@ -1,51 +0,0 @@
1
- class NepaliNumber:
2
-
3
- @classmethod
4
- def convert_and_add_comma(cls, number):
5
- return cls.add_comma(cls.convert(number))
6
-
7
- @staticmethod
8
- def convert(num):
9
- nepaliNumbers = ['०','१','२','३','४','५','६','७','८','९']
10
- np_num = ''
11
- en_num = str(num)
12
- for e in en_num:
13
- if e in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
14
- np_num = np_num+str(nepaliNumbers[int(e)])
15
- else:
16
- np_num = np_num+str(e)
17
- return np_num
18
-
19
- @staticmethod
20
- def revert(num):
21
- nepaliNumbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
22
- np_num = ''
23
- en_num = str(num)
24
- for e in en_num:
25
- if e in ['०','१','२','३','४','५','६','७','८','९']:
26
- np_num = np_num+str(nepaliNumbers[int(e)])
27
- else:
28
- np_num = np_num+str(e)
29
- return np_num
30
-
31
- @staticmethod
32
- def add_comma(number):
33
- number_with_comma = ""
34
- counter = 0
35
- for nepali_number_char in list(str(number))[::-1]:
36
- if counter == 3:
37
- number_with_comma = ',' + number_with_comma
38
-
39
- elif counter != 1 and counter != 3 and (counter-1) % 2 == 0:
40
- number_with_comma = ',' + number_with_comma
41
-
42
- number_with_comma = nepali_number_char + number_with_comma
43
-
44
- # increasing counter
45
- counter += 1
46
-
47
- return number_with_comma
48
-
49
- @staticmethod
50
- def add_comma_english(number):
51
- return '{:,}'.format(number)
@@ -1,220 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: nepali
3
- Version: 0.5.5
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/aj3sh/nepali
6
- Author: Ajesh Sen Thapa
7
- Author-email: aj3sshh@gmail.com
8
- License: UNKNOWN
9
- Keywords: nepali date conversion,convert date,nepali date time,python convert date,parse nepali date time
10
- Platform: UNKNOWN
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: pytz
17
-
18
- Nepali
19
- ======
20
-
21
- Python package for converting nepali date time to python's datetime easily. Also supports parsing and timezone features.
22
-
23
- Requirements
24
- ------------
25
- Python >= 3
26
-
27
-
28
- Installation
29
- -----------
30
- pip install nepali
31
-
32
-
33
- Features
34
- --------
35
- 1. Nepali datetime support
36
- 2. Parse nepali datetime
37
- 3. Nepali Characters (Months, Days, etc)
38
- 4. Number to nepali numbers and nepali numbers to english.
39
-
40
-
41
- nepalidate
42
- -------------
43
-
44
- Represents nepali date, converts English date to nepali date and nepali date to english date
45
-
46
- ```python
47
- from nepali.datetime import nepalidate
48
- ```
49
-
50
- **Creating new object**
51
- ```python
52
- # object with current date
53
- np_date = nepalidate(year, month, day)
54
-
55
- # object with today's date
56
- np_date = nepalidate.today()
57
-
58
- # parse date
59
- np_date = nepalidate.strptime('2078-01-12', format='%Y-%m-%d')
60
- ```
61
-
62
- **Object from python's datetime.date**
63
- ```python
64
- import datetime
65
-
66
- date = datetime.date.today()
67
- np_date = nepalidate.from_date(date)
68
- ```
69
-
70
- **Get python's datetime.date object**
71
- ```python
72
- np_date.to_date()
73
- ```
74
-
75
- **Get python's datetime.datetime object**
76
- ```python
77
- np_date.to_datetime()
78
- ```
79
-
80
-
81
- nepalidatetime
82
- -------------
83
-
84
- Represents nepali date time
85
-
86
- ```python
87
- from nepali.datetime import nepalidatetime
88
- ```
89
-
90
- **Creating new object**
91
- ```python
92
- # object with specific datetime
93
- np_datetime = nepalidatetime(year, month, day[, hour[, minute[, second]]]) # arguments must be nepali
94
-
95
- # object with current datetime
96
- np_datetime = nepalidatetime.now()
97
-
98
- # parse datetime
99
- np_datetime = nepalidatetime.strptime('2078-01-12 13:12', format='%Y-%m-%d %H:%M')
100
- ```
101
-
102
- **Object from python's datetime.datetime**
103
- ```python
104
- import datetime
105
-
106
- dt = datetime.datetime.now()
107
- np_datetime = nepalidatetime.from_datetime(dt)
108
- ```
109
-
110
- **Get nepalidate object**
111
- ```python
112
- np_datetime.date()
113
- ```
114
-
115
- **Get python's datetime.time object**
116
- ```python
117
- np_datetime.time()
118
- ```
119
-
120
- **Get python's datetime.datetime object**
121
- ```python
122
- np_datetime.to_datetime()
123
- ```
124
-
125
- **Date String Format**\
126
- _Equivalent to python's datetime strftime format_
127
- ```python
128
- npDateTime = nepalidatetime.now()
129
- print(npDateTime.strftime('%a %A %w %d %b %B %m %y %Y %H %I %p %M %S'))
130
- print(npDateTime.strftime_en('%a %A %w %d %b %B %m %y %Y %H %I %p %M %S'))
131
- ```
132
- ```
133
- बुध बुधबार ३ २६ मंसिर मंसिर ०८ ७५ २०७५ ११ ११ शुभप्रभात ०६ १३
134
- Wed Wednesday 3 26 Mangsir Mangsir 08 75 2075 11 11 AM 06 13
135
- ```
136
-
137
- **timedelta operations**
138
- ```python
139
- ndt = nepalidatetime.now()
140
- print(ndt + datetime.timedelta(hours=5))
141
- print(ndt - datetime.timedelta(hours=5))
142
- ```
143
-
144
- parse
145
- ---
146
- Parses datetime from a string.
147
-
148
- _parse uses very high cost method, so avoid this as much as you can._
149
-
150
- ```python
151
- from nepali.datetime import parser as nepalidatetime_parser
152
- ndt = nepalidatetime_parser.parse('29 Jestha, 2078, 1:30 PM')
153
- ```
154
-
155
- nepalihumanize
156
- -------------
157
-
158
- nepalihumanize converts nepalidatetime to nepali human readable form
159
-
160
- ```python
161
- from nepali.datetime import nepalihumanize
162
- ```
163
-
164
- **Creating new object**
165
- ```python
166
- # object from nepali datetime
167
- ndt = nepalidatetime.now()
168
- humanize_str = nepalihumanize(ndt)
169
-
170
- # object from python datetime
171
- dt = datetime.datetime.now()
172
- humanize_str = nepalihumanize(dt)
173
- ```
174
-
175
-
176
- **Humanize with threshold**\
177
- returns date in nepali characters if more than threshold(in seconds) else returns humanize form
178
- ```python
179
- humanize_str = nepalihumanize(ndt, threshold=60) # 60 seconds
180
-
181
- # custom format after threshold
182
- humanize_str = nepalihumanize(ndt, threshold=60, format='%Y-%m-%d') # 60 seconds
183
- ```
184
-
185
- For Django Template
186
- -------------------
187
-
188
- Add `'nepali'` to your `INSTALLED_APPS` setting.
189
- ```python
190
- INSTALLED_APPS = [
191
- ...
192
- 'nepali',
193
- ...
194
- ]
195
- ```
196
-
197
- IN your Template
198
-
199
- ```python
200
- {% load nepalidatetime %}
201
- ```
202
-
203
- ```python
204
- {% nepalinow %}
205
- ```
206
-
207
- ```python
208
- {% nepalinow '%Y-%m-%d' %}
209
- ```
210
-
211
- ```python
212
- {{ datetimeobj|nepalidate:"%Y-%m-%d" }}
213
- {{ datetimeobj|nepalidate_en:"%Y-%m-%d" }}
214
- ```
215
-
216
- ```python
217
- {{ datetimeobj|nepalihumanize }}
218
- ```
219
-
220
-
@@ -1,27 +0,0 @@
1
- nepali/__init__.py,sha256=h5vjqNrRXDujzQW7XxIj2Vjj5yEam_13I6EYeJqxYXk,15
2
- nepali/char.py,sha256=cEWGY3YoxEFu_7jVPj1123umgb076TxoxK9WVH1BNJA,2606
3
- nepali/datetime.py,sha256=GRlLsoLI6JOBhgriELfVUOwKRkOJiJFP-QyUQdxjPi8,28566
4
- nepali/exceptions.py,sha256=ccPx7jBXi-O8qgvN2sGZSlOKqeHhmuRp1IIcJqCrceY,323
5
- nepali/number.py,sha256=Xh0OWYo1XRvOysZ1qyyRcLw6uUp82oLYofLiNvJzcGI,1310
6
- nepali/timezone.py,sha256=WL7Lu4eeBSYRbjLr-GkVqzQdxG_JzlJjxomlP5Sla5A,565
7
- nepali/utils.py,sha256=F5qcmvA7lG4fXA4LFwy_9eK9y128xtPm7eigNRTK9po,2421
8
- nepali/datetime/__init__.py,sha256=kp1VUuw-vWNyJLrOmUGRyZAc5pFhaQD-F_YGVhMD7rg,386
9
- nepali/datetime/_converter.py,sha256=pyYDGvLgiencAuV8cUko8JLyGkdpFbs5b7fr2UbeJ_s,12530
10
- nepali/datetime/_datetime.py,sha256=oDK7hcc_G2lIfIAYQyBLqzZbrYN7vGBHxImy-4aztec,10284
11
- nepali/datetime/_formarter.py,sha256=0GkFrxtAQZ9BU7Py66T0ZRCxiDZPHwZNlOMl_Pim-14,6407
12
- nepali/datetime/_humanize.py,sha256=zI6H-5s8tcnYQnJ6DA4FMKmZtn2OQtPNGzndwTumd2A,3818
13
- nepali/datetime/parser/__init__.py,sha256=Mi8bW8f25vJkE0tLyf2nyDxppwmGGSbroD4EjryiIuU,74
14
- nepali/datetime/parser/_parser.py,sha256=IK0fW2UhG3HJsBYVnwETVimkz1g5qGcpX8cH_b-yZac,1753
15
- nepali/datetime/parser/validators.py,sha256=YD_YLnl4lg4Rr4g42DPsH_kbRFdt0YmO6-lj6qJmzbo,8648
16
- nepali/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- nepali/templatetags/nepalidatetime.py,sha256=WjIW4nko28FLMdmEtaOdKnrlFDoQtIcOA8Yh6v0scZQ,1225
18
- nepali/templatetags/nepalinumber.py,sha256=kxmH4ATu1u3MoWn9Rbz9qqQIZtKLnFoIM6VzA0_hiJk,334
19
- nepali/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- nepali/tests/test_datetime.py,sha256=zbLcdFCnmjLDHNZSG-tMDhxj9exh4yXrSbZkaHE4G6o,5648
21
- nepali/tests/test_humanize.py,sha256=-UMT_8CVEaL2JKVQiFdK3xOGVsH-aqOuBhxxlMvJKgc,522
22
- nepali/tests/test_parser.py,sha256=8LRiNkVGKh4MqtRn2SbRAPd-tUmZQV4gxieTkUBy7mc,6506
23
- nepali-0.5.5.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
24
- nepali-0.5.5.dist-info/METADATA,sha256=_kBUXfZe7Z0faldj5VbOBgDC7ORtizXZruDV74gKifc,4651
25
- nepali-0.5.5.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
26
- nepali-0.5.5.dist-info/top_level.txt,sha256=joX2GOfHg0KHYsDxi7eXDVTBQK0t6ZsvKz9uz7S6mFE,7
27
- nepali-0.5.5.dist-info/RECORD,,