nepali 1.1.0__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.
nepali/date_converter.py CHANGED
@@ -78,7 +78,7 @@ class NepaliDateConverter:
78
78
  ((31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30), 365),
79
79
  ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
80
80
  ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30), 365),
81
- ((31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 366),
81
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 366), # 2050
82
82
  ((31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30), 365),
83
83
  ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
84
84
  ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30), 365),
@@ -98,7 +98,7 @@ class NepaliDateConverter:
98
98
  ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
99
99
  ((31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30), 365),
100
100
  ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
101
- ((31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30), 365),
101
+ ((31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30), 365), # 2070
102
102
  ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
103
103
  ((31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30), 365),
104
104
  ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
@@ -108,27 +108,27 @@ class NepaliDateConverter:
108
108
  ((31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 366),
109
109
  ((31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30), 365),
110
110
  ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
111
- ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30), 365),
112
- ((31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30), 366),
113
- ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
114
- ((31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30), 365),
115
- ((31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30), 365),
116
- ((31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30), 366),
117
- ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
118
- ((31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30), 366),
119
- ((30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30), 365),
120
- ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
121
- ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
122
- ((31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30), 366),
123
- ((30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
124
- ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 365),
125
- ((31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30), 365),
126
- ((31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30), 366),
127
- ((30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30), 364),
128
- ((31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30), 366),
129
- ((31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31), 365),
111
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30), 365), # 2080
112
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 366), # 2081
113
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365), # 2082
114
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
115
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
116
+ ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 365),
117
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
118
+ ((31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30), 365),
119
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
120
+ ((30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31), 365),
121
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
122
+ ((31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30), 365),
123
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
124
+ ((31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31), 365),
125
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
126
+ ((31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30), 365),
127
+ ((31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31), 366),
128
+ ((31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30), 365),
129
+ ((31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30), 365),
130
130
  (
131
- (31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30),
131
+ (31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30),
132
132
  365,
133
133
  ), # 2099 BS - 2042/2043 AD
134
134
  ]
@@ -1,13 +1,15 @@
1
+ from __future__ import annotations
2
+
1
3
  from functools import cached_property
2
- from typing import Any, Dict, Optional, Union
4
+ from typing import Any
3
5
 
4
6
  from nepali.constants import NEPALI_MONTHS_EN, NEPALI_MONTHS_NE
5
7
 
6
8
 
7
9
  class NepaliMonthMeta(type):
8
- _cache: Dict[int, "nepalimonth"] = {}
10
+ _cache: dict[int, nepalimonth] = {}
9
11
 
10
- def __call__(cls, month: Union[int, str], *args, **kwargs) -> "nepalimonth":
12
+ def __call__(cls, month: int | str, *args, **kwargs) -> nepalimonth:
11
13
  """
12
14
  Parses the month data and manages the cache.
13
15
 
@@ -17,7 +19,7 @@ class NepaliMonthMeta(type):
17
19
  :rtype: nepalimonth
18
20
  :raises ValueError: If the given month is invalid.
19
21
  """
20
- value: Optional[int] = None
22
+ value: int | None = None
21
23
  value = None
22
24
 
23
25
  if isinstance(month, int):
@@ -1,13 +1,15 @@
1
+ from __future__ import annotations
2
+
1
3
  from functools import cached_property
2
- from typing import Any, Dict, Optional, Union
4
+ from typing import Any
3
5
 
4
6
  from nepali.constants import WEEKS_ABBR_EN, WEEKS_ABBR_NE, WEEKS_EN, WEEKS_NE
5
7
 
6
8
 
7
9
  class NepaliWeekMeta(type):
8
- _cache: Dict[int, "nepaliweek"] = {}
10
+ _cache: dict[int, nepaliweek] = {}
9
11
 
10
- def __call__(cls, week: Union[int, str], *args, **kwargs) -> "nepaliweek":
12
+ def __call__(cls, week: int | str, *args, **kwargs) -> nepaliweek:
11
13
  """
12
14
  Parses the week data and manages the cache.
13
15
 
@@ -17,7 +19,7 @@ class NepaliWeekMeta(type):
17
19
  :rtype: nepaliweek
18
20
  :raises ValueError: If the given week is invalid.
19
21
  """
20
- value: Optional[int] = None
22
+ value: int | None = None
21
23
 
22
24
  if isinstance(week, int):
23
25
  value = int(week)
@@ -1,8 +1,9 @@
1
1
  """
2
2
  validates parsing
3
3
  """
4
+ from __future__ import annotations
5
+
4
6
  import re
5
- from typing import Optional, Tuple
6
7
 
7
8
  from nepali.char import nepali_to_english_text
8
9
  from nepali.constants import NEPALI_MONTHS_EN, WEEKS_ABBR_EN, WEEKS_EN
@@ -157,7 +158,7 @@ def __convert_12_hour_to_24_hour(hour: int, am_pm: str) -> int:
157
158
  return hour
158
159
 
159
160
 
160
- def __calculate_year(data: dict) -> Optional[int]:
161
+ def __calculate_year(data: dict) -> int | None:
161
162
  """Calculates the year value from given data.
162
163
 
163
164
  :param data: The dictionary of the format:
@@ -217,7 +218,7 @@ def __calculate_day(data: dict) -> int:
217
218
  return 1
218
219
 
219
220
 
220
- def __calculate_hour_minute_seconds(data: dict) -> Tuple[int, int, int, int]:
221
+ def __calculate_hour_minute_seconds(data: dict) -> tuple[int, int, int, int]:
221
222
  """Calculates hour, minutes, seconds and microseconds from given data.
222
223
 
223
224
  :param data: The dictionary of the format:
@@ -256,7 +257,7 @@ def __calculate_hour_minute_seconds(data: dict) -> Tuple[int, int, int, int]:
256
257
  return hour, minute, second, fraction
257
258
 
258
259
 
259
- def __calculate_weekday(data: dict) -> Optional[nepaliweek]:
260
+ def __calculate_weekday(data: dict) -> nepaliweek | None:
260
261
  """Calculates the weekday of the date given in data.
261
262
 
262
263
  :param data: The data that describes the date.
nepali/locations/_data.py CHANGED
@@ -3494,8 +3494,8 @@ _location_data = [
3494
3494
  ],
3495
3495
  },
3496
3496
  {
3497
- "name": "Province 1",
3498
- "name_nepali": "प्रदेश नं. १",
3497
+ "name": "Koshi Province",
3498
+ "name_nepali": "कोशी प्रदेश",
3499
3499
  "districts": [
3500
3500
  {
3501
3501
  "name": "Taplejung",
@@ -1,9 +1,7 @@
1
- from typing import List, Tuple
2
-
3
1
  from .models import District, Municipality, MunicipalityType, Province
4
2
 
5
3
 
6
- def _loadData() -> Tuple[List[Province], List[District], List[Municipality]]:
4
+ def _loadData() -> tuple[list[Province], list[District], list[Municipality]]:
7
5
  from ._data import _location_data
8
6
 
9
7
  provinces = []
@@ -1,5 +1,4 @@
1
1
  from enum import Enum
2
- from typing import List
3
2
 
4
3
 
5
4
  class Location:
@@ -37,11 +36,11 @@ class Province(Location):
37
36
  self.__municipalities.append(municipality)
38
37
 
39
38
  @property
40
- def districts(self) -> List["District"]:
39
+ def districts(self) -> list["District"]:
41
40
  return self.__districts
42
41
 
43
42
  @property
44
- def municipalities(self) -> List["Municipality"]:
43
+ def municipalities(self) -> list["Municipality"]:
45
44
  return self.__municipalities
46
45
 
47
46
 
@@ -61,7 +60,7 @@ class District(Location):
61
60
  return self.__province
62
61
 
63
62
  @property
64
- def municipalities(self) -> List["Municipality"]:
63
+ def municipalities(self) -> list["Municipality"]:
65
64
  return self.__municipalities
66
65
 
67
66
 
@@ -2,7 +2,9 @@
2
2
  Contains the class for the nepalinumber feature
3
3
  """
4
4
 
5
- from typing import Any, Tuple, Type, Union
5
+ from __future__ import annotations
6
+
7
+ from typing import Any
6
8
 
7
9
  from .utils import NP_NUMBERS, NP_NUMBERS_SET, english_to_nepali
8
10
 
@@ -21,7 +23,7 @@ class nepalinumber:
21
23
  self.__value = self.__parse(value)
22
24
 
23
25
  def get_parse_exception(
24
- self, obj: object, ex_class: Type[Exception] = ValueError
26
+ self, obj: object, ex_class: type[Exception] = ValueError
25
27
  ) -> Exception:
26
28
  """
27
29
  Returns the exception object to be raised when the parse is failed.
@@ -30,7 +32,7 @@ class nepalinumber:
30
32
  :param obj: Object that is failed during the parse
31
33
  :type obj: object
32
34
  :param ex_class: Exception class type to be returned, defaults to ValueError
33
- :type ex_class: Type[Exception], optional
35
+ :type ex_class: type[Exception], optional
34
36
  :return: Exception object to be raised
35
37
  :rtype: Exception
36
38
  """
@@ -38,7 +40,7 @@ class nepalinumber:
38
40
  f"could not convert {obj.__class__.__name__} to {self.__class__.__name__}: '{obj}'"
39
41
  )
40
42
 
41
- def __parse(self, value: Any) -> Union[int, float]:
43
+ def __parse(self, value: Any) -> int | float:
42
44
  """
43
45
  Parses nepali number input into a valid value.
44
46
 
@@ -68,7 +70,7 @@ class nepalinumber:
68
70
 
69
71
  return self.__parse_object(value)
70
72
 
71
- def __parse_str(self, value: str) -> Union[int, float]:
73
+ def __parse_str(self, value: str) -> int | float:
72
74
  """
73
75
  Parses str object into int and float.
74
76
  This is a low level implementation.
@@ -112,7 +114,7 @@ class nepalinumber:
112
114
  i += 1
113
115
  return sign * result
114
116
 
115
- def __parse_object(self, obj: Any) -> Union[int, float]:
117
+ def __parse_object(self, obj: Any) -> int | float:
116
118
  """
117
119
  Parses object using __int__, __float__, and __str__.
118
120
 
@@ -129,7 +131,7 @@ class nepalinumber:
129
131
  # object conversion must raise TypeError if fails
130
132
  raise self.get_parse_exception(obj, ex_class=TypeError) from None
131
133
 
132
- def __convert_or_return(self, obj) -> Union["nepalinumber", object]:
134
+ def __convert_or_return(self, obj) -> nepalinumber | object:
133
135
  """
134
136
  Will try to parse the given object and convert to nepalinumber
135
137
  else will return the same object
@@ -165,7 +167,7 @@ class nepalinumber:
165
167
  """
166
168
  return float(self.__value)
167
169
 
168
- def __add(self, other) -> Union[int, float]:
170
+ def __add(self, other) -> int | float:
169
171
  """
170
172
  Adds the value in the object with the passed object
171
173
 
@@ -179,7 +181,7 @@ class nepalinumber:
179
181
 
180
182
  return self.__value + other
181
183
 
182
- def __mul(self, other) -> Union[int, float]:
184
+ def __mul(self, other) -> int | float:
183
185
  """
184
186
  Multiplies the value in the object with the passed object
185
187
 
@@ -219,13 +221,13 @@ class nepalinumber:
219
221
 
220
222
  return self.__value != other
221
223
 
222
- def __neg__(self) -> "nepalinumber":
224
+ def __neg__(self) -> nepalinumber:
223
225
  """
224
226
  Returns the negative value of the nepalinumber value
225
227
  """
226
228
  return nepalinumber((-1) * self.__value)
227
229
 
228
- def __add__(self, other) -> Union["nepalinumber", object]:
230
+ def __add__(self, other) -> nepalinumber | object:
229
231
  """
230
232
  Called when the addition operator + is used after
231
233
  the nepalinumber object
@@ -242,7 +244,7 @@ class nepalinumber:
242
244
  except TypeError:
243
245
  return NotImplemented
244
246
 
245
- def __radd__(self, other) -> Union["nepalinumber", object]:
247
+ def __radd__(self, other) -> nepalinumber | object:
246
248
  """
247
249
  Called when the addition operator + is used before
248
250
  the nepalinumber object
@@ -259,7 +261,7 @@ class nepalinumber:
259
261
  except TypeError:
260
262
  return NotImplemented
261
263
 
262
- def __sub__(self, other) -> Union["nepalinumber", object]:
264
+ def __sub__(self, other) -> nepalinumber | object:
263
265
  """
264
266
  Called when the subtraction operator - is used after
265
267
  the nepalinumber object
@@ -278,7 +280,7 @@ class nepalinumber:
278
280
  except TypeError:
279
281
  return NotImplemented
280
282
 
281
- def __rsub__(self, other) -> Union["nepalinumber", object]:
283
+ def __rsub__(self, other) -> nepalinumber | object:
282
284
  """
283
285
  Called when the subtraction operator - is used before
284
286
  the nepalinumber object
@@ -298,7 +300,7 @@ class nepalinumber:
298
300
  except TypeError:
299
301
  return NotImplemented
300
302
 
301
- def __mul__(self, other) -> Union["nepalinumber", object]:
303
+ def __mul__(self, other) -> nepalinumber | object:
302
304
  """
303
305
  Called when the multiplication operator * is used after
304
306
  the nepalinumber object
@@ -318,7 +320,7 @@ class nepalinumber:
318
320
  except TypeError:
319
321
  return NotImplemented
320
322
 
321
- def __rmul__(self, other) -> Union["nepalinumber", object]:
323
+ def __rmul__(self, other) -> nepalinumber | object:
322
324
  """
323
325
  Called when the multiplication operator * is used before
324
326
  the nepalinumber object
@@ -338,7 +340,7 @@ class nepalinumber:
338
340
  except TypeError:
339
341
  return NotImplemented
340
342
 
341
- def __truediv__(self, other) -> Union["nepalinumber", object]:
343
+ def __truediv__(self, other) -> nepalinumber | object:
342
344
  """
343
345
  Called when the division operator / is used after
344
346
  the nepalinumber object
@@ -357,7 +359,7 @@ class nepalinumber:
357
359
  except TypeError:
358
360
  return NotImplemented
359
361
 
360
- def __rtruediv__(self, other) -> Union["nepalinumber", object]:
362
+ def __rtruediv__(self, other) -> nepalinumber | object:
361
363
  """
362
364
  Called when the division operator / is used before
363
365
  the nepalinumber object
@@ -377,7 +379,7 @@ class nepalinumber:
377
379
  except TypeError:
378
380
  return NotImplemented
379
381
 
380
- def __floordiv__(self, other) -> Union["nepalinumber", object]:
382
+ def __floordiv__(self, other) -> nepalinumber | object:
381
383
  """
382
384
  Called when the floor/integer division operator // is used
383
385
  after the nepalinumber object
@@ -396,7 +398,7 @@ class nepalinumber:
396
398
  except TypeError:
397
399
  return NotImplemented
398
400
 
399
- def __rfloordiv__(self, other) -> Union["nepalinumber", object]:
401
+ def __rfloordiv__(self, other) -> nepalinumber | object:
400
402
  """
401
403
  Called when the floor/integer division operator // is used
402
404
  before the nepalinumber object
@@ -416,7 +418,7 @@ class nepalinumber:
416
418
  except TypeError:
417
419
  return NotImplemented
418
420
 
419
- def __mod__(self, other) -> Union["nepalinumber", object]:
421
+ def __mod__(self, other) -> nepalinumber | object:
420
422
  """
421
423
  Called when the modulo operator % is used after
422
424
  the nepalinumber object
@@ -436,7 +438,7 @@ class nepalinumber:
436
438
  except TypeError:
437
439
  return NotImplemented
438
440
 
439
- def __rmod__(self, other) -> Union["nepalinumber", object]:
441
+ def __rmod__(self, other) -> nepalinumber | object:
440
442
  """
441
443
  Called when the modulo operator % is used before
442
444
  the nepalinumber object
@@ -458,7 +460,7 @@ class nepalinumber:
458
460
 
459
461
  def __divmod__(
460
462
  self, other
461
- ) -> Tuple[Union["nepalinumber", object], Union["nepalinumber", object]]:
463
+ ) -> tuple[nepalinumber | object, nepalinumber | object]:
462
464
  """
463
465
  Called when the built-in function divmod() is used
464
466
  with nepalinumber as the dividend and other as divisor
@@ -483,7 +485,7 @@ class nepalinumber:
483
485
 
484
486
  def __rdivmod__(
485
487
  self, other
486
- ) -> Tuple[Union["nepalinumber", object], Union["nepalinumber", object]]:
488
+ ) -> tuple[nepalinumber | object, nepalinumber | object]:
487
489
  """
488
490
  Called when the built-in function divmod() is used
489
491
  with nepalinumber as the divisor and other as dividend
@@ -506,7 +508,7 @@ class nepalinumber:
506
508
  except TypeError:
507
509
  return NotImplemented
508
510
 
509
- def __pow__(self, other) -> Union["nepalinumber", object]:
511
+ def __pow__(self, other) -> nepalinumber | object:
510
512
  """
511
513
  Called when the power operator ** is used after
512
514
  the nepalinumber object
@@ -526,7 +528,7 @@ class nepalinumber:
526
528
  except TypeError:
527
529
  return NotImplemented
528
530
 
529
- def __rpow__(self, other) -> Union["nepalinumber", object]:
531
+ def __rpow__(self, other) -> nepalinumber | object:
530
532
  """
531
533
  Called when the power operator ** is used before
532
534
  the nepalinumber object
nepali/phone_number.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import re
2
2
  from enum import Enum
3
- from typing import Union
4
3
 
5
4
  _mobile_number_re = re.compile(r"^(?:\+977|977)?(?:-)?(?:98|97|96)\d{8}$")
6
5
  _landline_number_re = re.compile(
@@ -93,7 +92,7 @@ def parse(number: str):
93
92
  return None
94
93
 
95
94
 
96
- def _get_operator(number: str) -> Union[Operator, None]:
95
+ def _get_operator(number: str) -> Operator | None:
97
96
  """
98
97
  Returns operator from the number.
99
98
  NOTE: The number should be 10digit mobile number.
@@ -9,6 +9,7 @@ from nepali.date_converter import converter
9
9
 
10
10
 
11
11
  class TestNepaliDateConverter(unittest.TestCase):
12
+ """tests for date_converter.converter module"""
12
13
  # test date range
13
14
  def test_english_date_range(self):
14
15
  self.assertEqual(converter.en_min_year(), 1944)
@@ -49,6 +50,12 @@ class TestNepaliDateConverter(unittest.TestCase):
49
50
  self.assertEqual(m, 4)
50
51
  self.assertEqual(d, 29)
51
52
 
53
+ def test_converter_english_to_nepali_returns_valid_past_nepali_date2(self):
54
+ y, m, d = converter.english_to_nepali(1944, 5, 28)
55
+ self.assertEqual(y, 2001)
56
+ self.assertEqual(m, 2)
57
+ self.assertEqual(d, 15)
58
+
52
59
  def test_converter_english_to_nepali_returns_valid_recent_nepali_date(self):
53
60
  y, m, d = converter.english_to_nepali(2023, 1, 28)
54
61
  self.assertEqual(y, 2079)
@@ -98,25 +105,31 @@ class TestNepaliDateConverter(unittest.TestCase):
98
105
  with self.assertRaises(Exception):
99
106
  converter.nepali_to_english(2079, 1, 40)
100
107
 
101
- def test_converter_nepali_to_englishReturnsValidPastEnglishDate(self):
108
+ def test_converter_nepali_to_english_returns_valid_past_english_date(self):
102
109
  y, m, d = converter.nepali_to_english(2051, 4, 29)
103
110
  self.assertEqual(y, 1994)
104
111
  self.assertEqual(m, 8)
105
112
  self.assertEqual(d, 13)
106
113
 
107
- def test_converter_nepali_to_englishReturnsValidRecentEnglishDate(self):
114
+ def test_converter_nepali_to_english_returns_valid_past_english_date2(self):
115
+ y, m, d = converter.nepali_to_english(2001, 2, 15)
116
+ self.assertEqual(y, 1944)
117
+ self.assertEqual(m, 5)
118
+ self.assertEqual(d, 28)
119
+
120
+ def test_converter_nepali_to_english_returns_valid_recent_english_date(self):
108
121
  y, m, d = converter.nepali_to_english(2079, 10, 14)
109
122
  self.assertEqual(y, 2023)
110
123
  self.assertEqual(m, 1)
111
124
  self.assertEqual(d, 28)
112
125
 
113
- def test_converter_nepali_to_englishReturnsValidFutureEnglishDate(self):
126
+ def test_converter_nepali_to_english_returns_valid_future_english_date(self):
114
127
  y, m, d = converter.nepali_to_english(2087, 8, 10)
115
128
  self.assertEqual(y, 2030)
116
129
  self.assertEqual(m, 11)
117
130
  self.assertEqual(d, 26)
118
131
 
119
- def test_converter_nepali_to_englishReturnsValidEnglishLeapYearDate(self):
132
+ def test_converter_nepali_to_english_returns_valid_english_leap_year_date(self):
120
133
  y, m, d = converter.nepali_to_english(2080, 12, 15)
121
134
  self.assertEqual(y, 2024)
122
135
  self.assertEqual(m, 3)
@@ -3,7 +3,6 @@ To run only this unit test use the command below.
3
3
 
4
4
  python -m unittest nepali/tests/test_number.py -v
5
5
  """
6
- import sys
7
6
  import unittest
8
7
 
9
8
  from nepali import number
@@ -1812,13 +1811,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
1812
1811
  with self.assertRaises(ZeroDivisionError) as ze:
1813
1812
  _ = self.nepalinumber_float_10_1 // 0
1814
1813
 
1815
- python_version = sys.version_info
1816
-
1817
- if python_version.major >= 3:
1818
- if python_version.minor <= 8:
1819
- self.assertEqual(str(ze.exception), "float divmod()")
1820
- else:
1821
- self.assertEqual(str(ze.exception), "float floor division by zero")
1814
+ self.assertEqual(str(ze.exception), "float floor division by zero")
1822
1815
 
1823
1816
  def test_nepalinumber_throws_error_when_zero_nepalinumber_floor_divides_other_numbers(
1824
1817
  self,
@@ -1831,13 +1824,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
1831
1824
  with self.assertRaises(ZeroDivisionError) as ze:
1832
1825
  _ = 12.1 // self.nepalinumber_zero
1833
1826
 
1834
- python_version = sys.version_info
1835
-
1836
- if python_version.major >= 3:
1837
- if python_version.minor <= 8:
1838
- self.assertEqual(str(ze.exception), "float divmod()")
1839
- else:
1840
- self.assertEqual(str(ze.exception), "float floor division by zero")
1827
+ self.assertEqual(str(ze.exception), "float floor division by zero")
1841
1828
 
1842
1829
  def test_nepalinumber_throws_error_when_floor_divided_by_zero_nepalinumber(self):
1843
1830
  with self.assertRaises(ZeroDivisionError) as ze:
@@ -1848,13 +1835,7 @@ class TestNepaliNumberArithmeticOperations(unittest.TestCase):
1848
1835
  with self.assertRaises(ZeroDivisionError) as ze:
1849
1836
  _ = self.nepalinumber_float_10_1 // self.nepalinumber_zero
1850
1837
 
1851
- python_version = sys.version_info
1852
-
1853
- if python_version.major >= 3:
1854
- if python_version.minor <= 8:
1855
- self.assertEqual(str(ze.exception), "float divmod()")
1856
- else:
1857
- self.assertEqual(str(ze.exception), "float floor division by zero")
1838
+ self.assertEqual(str(ze.exception), "float floor division by zero")
1858
1839
 
1859
1840
  # mod
1860
1841
  # nepalinumber positive integer modulo tests
@@ -3124,3 +3105,48 @@ class TestNepaliNumberMethods(unittest.TestCase):
3124
3105
  def test_nepalinumber_str_ne_for_zero(self):
3125
3106
  self.assertEqual(self.nepalinumber_integer_0.str_ne(), "०")
3126
3107
  self.assertEqual(self.nepalinumber_float_0_0.str_ne(), "०.०")
3108
+
3109
+ # __str__ tests
3110
+ def test_nepalinumber_str_returns_string_representation(self):
3111
+ self.assertEqual(str(self.nepalinumber_integer_1), "1")
3112
+ self.assertEqual(str(self.nepalinumber_float_1_25), "1.25")
3113
+ self.assertEqual(str(self.nepalinumber_negative_integer_1), "-1")
3114
+
3115
+ # __repr__ tests
3116
+ def test_nepalinumber_repr_returns_string_representation(self):
3117
+ self.assertEqual(repr(self.nepalinumber_integer_1), "1")
3118
+ self.assertEqual(repr(self.nepalinumber_float_1_25), "1.25")
3119
+
3120
+ # __int__ tests
3121
+ def test_nepalinumber_int_returns_integer(self):
3122
+ self.assertEqual(int(self.nepalinumber_integer_1), 1)
3123
+ self.assertEqual(int(self.nepalinumber_float_1_25), 1)
3124
+ self.assertEqual(int(self.nepalinumber_negative_integer_1), -1)
3125
+
3126
+ # __ne__ tests
3127
+ def test_nepalinumber_ne_with_nepalinumber(self):
3128
+ self.assertTrue(self.nepalinumber_integer_1 != self.nepalinumber_integer_0)
3129
+ self.assertFalse(self.nepalinumber_integer_1 != nepalinumber(1))
3130
+
3131
+ def test_nepalinumber_ne_with_int(self):
3132
+ self.assertTrue(self.nepalinumber_integer_1 != 5)
3133
+ self.assertFalse(self.nepalinumber_integer_1 != 1)
3134
+
3135
+ def test_nepalinumber_ne_with_float(self):
3136
+ self.assertTrue(self.nepalinumber_float_1_25 != 1.5)
3137
+ self.assertFalse(self.nepalinumber_float_1_25 != 1.25)
3138
+
3139
+ # __neg__ tests
3140
+ def test_nepalinumber_negation(self):
3141
+ self.assertEqual(-self.nepalinumber_integer_1, nepalinumber(-1))
3142
+ self.assertEqual(-self.nepalinumber_negative_integer_1, nepalinumber(1))
3143
+ self.assertEqual(-self.nepalinumber_float_1_25, nepalinumber(-1.25))
3144
+
3145
+ # __eq__ with non-nepalinumber tests
3146
+ def test_nepalinumber_eq_with_int(self):
3147
+ self.assertTrue(self.nepalinumber_integer_1 == 1)
3148
+ self.assertFalse(self.nepalinumber_integer_1 == 2)
3149
+
3150
+ def test_nepalinumber_eq_with_float(self):
3151
+ self.assertTrue(self.nepalinumber_float_1_25 == 1.25)
3152
+ self.assertFalse(self.nepalinumber_float_1_25 == 1.5)
nepali/timezone.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import datetime
2
- from typing import Union
3
2
 
4
3
  from .constants import NEPAL_TIMEZONE
5
4
 
@@ -28,7 +27,7 @@ class NepaliTimeZone(datetime.tzinfo):
28
27
  return isinstance(o, self.__class__)
29
28
 
30
29
 
31
- def get_timezone() -> Union[datetime.tzinfo, None]:
30
+ def get_timezone() -> datetime.tzinfo | None:
32
31
  """
33
32
  Returns current device's timezone.
34
33
  Timezone of the machine.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: nepali
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
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
5
  Home-page: https://github.com/opensource-nepal/py-nepali
6
6
  Author: opensource-nepal
@@ -10,10 +10,27 @@ Project-URL: Source, https://github.com/opensource-nepal/py-nepali
10
10
  Project-URL: Changelog, https://github.com/opensource-nepal/py-nepali/blob/main/CHANGELOG.md
11
11
  Keywords: nepali date conversion,convert date,nepali date time,python convert date,parse nepali date time
12
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
13
17
  Classifier: License :: OSI Approved :: MIT License
14
18
  Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.10
15
20
  Description-Content-Type: text/markdown
16
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
17
34
 
18
35
  # nepali
19
36
 
@@ -50,7 +67,7 @@ phone_number.parse("+977-9845217789")
50
67
 
51
68
  ## Requirements
52
69
 
53
- Python >= 3
70
+ Python >= 3.10
54
71
 
55
72
  ## Installation
56
73
 
@@ -310,7 +327,7 @@ np_datetime = parse("Jestha 15, 2079") # 2079-02-15 00:00:00
310
327
 
311
328
  | Directive | Meaning | Example |
312
329
  | --------- | --------------------------------------------------------- | ------------------------------ |
313
- | `%A` | Weekday as locale’s abbreviated name. | Sun, Mon, …, Sat (आइत, सोम, …) |
330
+ | `%a` | Weekday as locale’s abbreviated name. | Sun, Mon, …, Sat (आइत, सोम, …) |
314
331
  | `%A` | Weekday as locale’s full name. | Sunday, Monday, …, Saturday |
315
332
  | `%d` | Day of the month as a zero-padded decimal number. | 01, 02, …, 31 |
316
333
  | `%-d` | Day of the month as a decimal number. | 1, 2, …, 31 |
@@ -456,4 +473,4 @@ We have created a new Django package called [django-nepali](https://github.com/o
456
473
 
457
474
  ## Contribution
458
475
 
459
- We appreciate feedback and contribution to this package. To get started please see our [contribution guide](CONTRIBUTION.md)
476
+ We appreciate feedback and contribution to this package. To get started please see our [contribution guide](./CONTRIBUTING.md)
@@ -1,46 +1,46 @@
1
1
  nepali/__init__.py,sha256=8Vx8S0r8UT5PoFdlGHBp59j84si87m4mWgGipzwhVvs,16
2
2
  nepali/char.py,sha256=WglBe0AefpsHwIXaPXr0FVjdI4qvmr06U8kSQLtvjdQ,3437
3
3
  nepali/constants.py,sha256=FA5qvFaiNKyQ5APQytDovbr9tBPIITgLpPMrR0UlbsY,1309
4
- nepali/date_converter.py,sha256=ZRmjTl7GjKW8Gvx2KKN3kyAd62lepHk8f6SJ8f0kLzQ,13551
4
+ nepali/date_converter.py,sha256=9LX3QLGrZUxbF52oQLLhSk2Wv8LKQqZhfdo6T_LUK_4,13591
5
5
  nepali/exceptions.py,sha256=CKg1wEUuzcog7w8Q7pGBNthi9oTOeg_3Aapx1WaTveY,329
6
- nepali/phone_number.py,sha256=QCAas5yyVVAXiS-CkO_-BGINmVTj96IwOyIn0-XVDZo,4172
7
- nepali/timezone.py,sha256=qRO9ALaEDH4LkPPKGtUlHbDo6TysfQclgVmmQmFrkMU,1995
6
+ nepali/phone_number.py,sha256=bsmvIgTPZEOBXzWWN1Uu2I2WsFEr-tNCVwZOZi3S2tQ,4141
7
+ nepali/timezone.py,sha256=Sm8Vmd9UwpPA0VNzcnjnIodkdvkzU-5ZQwW3b7RmYI4,1964
8
8
  nepali/utils.py,sha256=rOHuHuUZzcTCQTfFXn3RneS9lx9RbtDTifnkO-buoDc,241
9
9
  nepali/datetime/__init__.py,sha256=5tfqVCXri3zACb2twLI1QcYw9wp4-Omj6tJhSny-mxo,427
10
10
  nepali/datetime/_datetime.py,sha256=jIeSotLQ_rLe5keRGZt31usDIt0RiXuM4SsPkbxmFsI,12049
11
11
  nepali/datetime/_formatter.py,sha256=U0Fe-mPwM25VSru124SRG9Olv0FD1WwaFjR22G9TuOU,8744
12
12
  nepali/datetime/_humanize.py,sha256=mfucIbpdZqq2-GjolfhLUP22dKkmy7484hE1FpzHvnM,3636
13
- nepali/datetime/_nepalimonth.py,sha256=chyLZFh3vDt4StUia5GGxDNCTBLBjVatK4uYiumo5po,3224
14
- nepali/datetime/_nepaliweek.py,sha256=kKuya3qo8lUokkuOGsgcsiHJx2Hf6Ith0nPZsaA1iQI,3400
13
+ nepali/datetime/_nepalimonth.py,sha256=lSKvtS5q_WO0ImDEZgNAhZ9PkwbqfH_3f35qNKpX9uA,3224
14
+ nepali/datetime/_nepaliweek.py,sha256=rlCUlqkfN3IM6SsVmk0sbjA5ZxcYqC_Juw0uzFovJFQ,3400
15
15
  nepali/datetime/utils.py,sha256=UpBhiwRrNg8bpTW018_gSzk3w8BMZiqVcK0C3x16JYU,1482
16
16
  nepali/datetime/parser/__init__.py,sha256=IXGIIG8KO3VP4BPPQegoz2LRven1L9pLkM0mYbvHf7I,81
17
17
  nepali/datetime/parser/_parser.py,sha256=U7W3wrY5hAPoB9XMD5KMT8OCEy6ZyIF48UHXnJRfny0,1930
18
- nepali/datetime/parser/validators.py,sha256=Zd9KFEUVkWKY57_Oa1S7jOnPsnJjvEbNp38QwTglgeM,10597
18
+ nepali/datetime/parser/validators.py,sha256=6BkYsfVLVzYdDCDJALtfm3cKaFmzE0_esp8C7t_WXYk,10592
19
19
  nepali/locations/__init__.py,sha256=kaBcuMBHrf38Zj7BTXRIwP6rdXnzc_bpQMcig8BzDcQ,117
20
- nepali/locations/_data.py,sha256=8qrkNLZAMgqTxopPaFOcO9HpwqapF7WfjPL20Qrcvyc,216494
21
- nepali/locations/_locations.py,sha256=DpnE4lcTbxTDfKv5EsCupDqCi2K5-jSDICzF5DpKpss,1348
22
- nepali/locations/models.py,sha256=OZ2C-ZK2Fz-eC8up-j0HLliFWOqMMyO_cvzTLkTIFs8,2870
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
23
  nepali/locations/utils.py,sha256=dPV8tJDTajgfJaQ6qNMgnemMTlilYzza0m6DhrxkdOs,1546
24
24
  nepali/number/__init__.py,sha256=r1qwwG-HQ_QtMt_qvfBZMmBKgWQArBERYRs4tJdFjKY,384
25
- nepali/number/_nepalinumber.py,sha256=dwI-u7jXUi8SajjOT28yhDos1x4vykSSPvhVz4NRaTk,19561
25
+ nepali/number/_nepalinumber.py,sha256=0BnU43cMHSM9ntxo3w3dvNmGRTAjnyJdicvFPdJgyB4,19393
26
26
  nepali/number/_number.py,sha256=qPqXSeU7YxIR1IXxjgmfFeIlCWre8_6IHtPD_0ip20I,1892
27
27
  nepali/number/utils.py,sha256=ieGpY0DK5_FZaTvSKp8q4hMepjWqyXtGtf7T7-0iVp4,1878
28
28
  nepali/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  nepali/templatetags/nepalidatetime.py,sha256=g6UtfkToZtVDVe_Z9aGPwYPhNrPpZzvfi1bzFdTjSpg,5789
30
30
  nepali/templatetags/nepalinumber.py,sha256=hjq0cxI1o_uny_8aH9skUhqzhWi4YvnvY3ivdt1ulGU,2452
31
31
  nepali/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- nepali/tests/test_date_converter.py,sha256=rVUelyeuPziIN_1YewZqa0bgzCG-BzbjH_Dk7AKkJy4,5282
32
+ nepali/tests/test_date_converter.py,sha256=9Ubr_SytLIIj-ptF7vhbQVjOEZQ2PVauXj6E4utYIHw,5830
33
33
  nepali/tests/test_datetime.py,sha256=YjXGxnqeu4ytn5HpDU4CxwYTNmiB-KilJv10T2Wc5Eo,13581
34
34
  nepali/tests/test_humanize.py,sha256=DX0-I1aXZkBNSPtXKbRrIPiBVxzVaFRItlDwx4lDzko,3845
35
35
  nepali/tests/test_locations.py,sha256=DoiqiLh8FdvervTyqbbeG-f7QQDTOiQ4GJS68OheNPs,5968
36
36
  nepali/tests/test_nepalimonth.py,sha256=1e-nFpCvk_JGUhRtjAL9_NDck2Ue828Gp3sN_uAWGxU,6575
37
37
  nepali/tests/test_nepaliweek.py,sha256=ycGE3gY1d6JjF0VyAy5DbVGg3ayLcRTwAHruSqAWF_4,6468
38
- nepali/tests/test_number.py,sha256=wDrAygSskvsLWGD3NqL8ButVdCwKbouzzmdL-ncqjpY,117664
38
+ nepali/tests/test_number.py,sha256=2jBadNFrslbvW0fjVGvRTe-0eVeFy8bVEX6ucOuG4Z4,119021
39
39
  nepali/tests/test_parser.py,sha256=_p6H09Ybw-sTRpNNgf7qMibEtnubI-HRECxrbLlgRnw,6712
40
40
  nepali/tests/test_phone_number.py,sha256=fswHlwgaiS3outmHOevNj1IVh0ZOYyrvuFKYBYODGRE,11726
41
41
  nepali/tests/test_timezone.py,sha256=-GBtiRU5msL9SjPeBBrZuXKMn89k_Q4mqhiT48W0BJE,6542
42
- nepali-1.1.0.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
43
- nepali-1.1.0.dist-info/METADATA,sha256=qAeuDu_ItzCjEHcbDisDuaVMqQRmKzBK4hVm0QDCfhY,14154
44
- nepali-1.1.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
45
- nepali-1.1.0.dist-info/top_level.txt,sha256=joX2GOfHg0KHYsDxi7eXDVTBQK0t6ZsvKz9uz7S6mFE,7
46
- nepali-1.1.0.dist-info/RECORD,,
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.40.0)
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.