# nepali
[![PyPI version](https://badge.fury.io/py/nepali.svg)](https://badge.fury.io/py/nepali)
[![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)
[![Downloads](https://img.shields.io/pypi/dm/nepali.svg?maxAge=180)](https://pypi.org/project/nepali/)
[![codecov](https://codecov.io/gh/opensource-nepal/py-nepali/branch/main/graph/badge.svg?token=PTUHYWCJ4I)](https://codecov.io/gh/opensource-nepal/py-nepali)
`nepali` is a python package containing features that will be useful for Nepali projects.
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.
## Example
```python
import datetime
from nepali import phone_number
from nepali.datetime import nepalidate, parser
nepali_datetime = parser.parse('2079-02-15')
# 2079-02-15 00:00:00
date = datetime.date(2017, 3, 15)
nepali_date = nepalidate.from_date(date)
# 2073-12-02
phone_number.parse("+977-9845217789")
# {
# 'type': 'Mobile',
# 'number': '9845217789',
# 'operator': <Operator: Nepal Telecom>
# }
```
## Requirements
Python >= 3
## Installation
pip install nepali
## Features
1. [Date and Time](#date-and-time)
- [date_converter](#date_converter)
- [nepalidate](#nepalidate)
- [nepalidatetime](#nepalidatetime)
- [nepalihumanize](#nepalihumanize)
- [timezone](#timezone)
- [parse](#parse)
- [strftime() and strptime() Format Codes](#strftime-and-strptime-format-codes)
1. [Numbers](#numbers)
- [nepalinumber](#nepalinumber)
1. [Phone Number](#phone-number)
1. [Locations](#locations)
1. [For Django Template](#for-django-template)
## Date and Time
### date_converter
Date converter module converts english date to nepali and nepali date to english. It doesn't contain any extra functionality.
**Convert English date to Nepali date**
```python
from nepali.date_converter import converter
np_year, np_month, np_date = converter.english_to_nepali(en_year, en_month, en_date)
```
Example
```python
from nepali.date_converter import converter
np_year, np_month, np_date = converter.english_to_nepali(2023, 2, 7)
print(np_year, np_month, np_date) # 2079 10 24
```
**Convert Nepali date to English date**
```python
from nepali.date_converter import converter
en_year, en_month, en_date = converter.nepali_to_english(np_year, np_month, np_date)
```
Example
```python
from nepali.date_converter import converter
en_year, en_month, en_date = converter.nepali_to_english(2079, 10, 24)
print(en_year, en_month, en_date) # 2023 2 7
```
### nepalidate
**Creating a new nepalidate object**
```python
from nepali.datetime import nepalidate
# nepalidate object with year, month, day
np_date = nepalidate(year, month, day)
# nepalidate object with today's date
np_date = nepalidate.today()
# parse nepali date
np_date = nepalidate.strptime('2078-01-18', format='%Y-%m-%d')
```
**Getting nepalidate object from python datetime**
```python
# from date object
np_date = nepalidate.from_date(date_obj)
# from datetime object
np_date = nepalidate.from_datetime(datetime_obj)
```
**Attributes and Methods**
```python
np_date.year # 2078 (year)
np_date.month # 1 (month)
np_date.day # 18 (day)
np_date.to_date() # datetime.date object
np_date.to_datetime() # datetime.datetime object
np_date.to_nepalidatetime() # nepalidatetime object
np_date.strftime("%Y-%m-%d") # 2078-01-18
np_date.strftime_ne("%Y-%m-%d") # २०७८-०१-१८
np_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6
```
### nepalidatetime
**Creating a new nepalidatetime object**
```python
from nepali.datetime import nepalidatetime
# nepalidate object with year, month, day, hour, minute, second
np_datetime = nepalidatetime(year, month, day[, hour[, minute[, second]]])
# nepalidate object with current date and time
np_datetime = nepalidate.now()
np_datetime = nepalidate.today()
# parse nepali datetime
np_datetime = nepalidatetime.strptime('2078-01-12 13:12', format='%Y-%m-%d %H:%M')
```
**Getting nepalidatetime object from python datetime**
```python
# from date object
np_datetime = nepalidatetime.from_date(date_obj)
# from datetime object
np_datetime = nepalidatetime.from_datetime(datetime_obj)
```
**Getting nepalidatetime object from nepalidate**
```python
np_datetime = nepalidatetime.from_nepalidate(nepali_date)
```
**Attributes and Methods**
```python
np_date.year # 2078 (year)
np_date.month # 1 (month)
np_date.day # 18 (day)
np_date.hour # 23 (hour)
np_date.minute # 59 (minute)
np_date.second # 59 (day)
np_date.to_date() # datetime.date object
np_date.to_datetime() # datetime.datetime object
np_date.to_nepalidate() # nepalidatetime object
np_date.to_time() # nepalitime object (datetime.time compatible)
np_date.strftime("%Y-%m-%d %H:%M") # 2078-01-18 23:59
np_date.strftime_ne("%Y-%m-%d %H:%M") # २०७८-०१-१८ २३:५९
np_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6
```
**Timedelta support**
```python
# timedelta addition and subtraction
np_datetime - datetime.timedelta(days=3) # returns nepalidatetime
# comparison between two dates
np_datetime1 - np_datetime2 # returns timedelta object
np_datetime1 < np_datetime2 # returns bool (True/False)
np_datetime1 >= datetime.datetime.now() # returns bool (True/False)
...
```
### nepalihumanize
Returns readable form of nepali date.
```python
from nepali.datetime import nepalihumanize
nepalihumanize(datetime, [threshold, format])
```
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.
Example
```python
from nepali.datetime import nepalihumanize, nepalidatetime
np_datetime = nepalidatetime(2079, 10, 5)
output = nepalihumanize(np_datetime)
# output: ३ महिना अघि
output = nepalihumanize(np_datetime, threshold=1400)
# 1400 = 2 * 30 * 24; two months threshold
# output: माघ ०५, २०७९
```
### timezone
**NepaliTimeZone**
You can use `NepaliTimeZone` directly to your datetime object.
```python
from nepali.timezone import NepaliTimeZone
datetime.datetime(2018, 8, 12, 16, 23, tzinfo=NepaliTimeZone())
```
**now**
Returns current datetime object with timezone
```python
from nepali import timezone
timezone.now()
```
`datetime.now()` vs `timezone.now()`:
`datetime.now()` doesn't contain timezone, but `timezone.now()` will contain timezone of the system.
**utc_now**
Returns current UTC datetime object (with timezone UTC)
```python
from nepali import timezone
timezone.utc_now()
```
### parse
Parses date with commonly used date formats. Auto detects date format. If you are sure about the format, please use `strptime`.
```python
from nepali.datetime.parser import parse
np_datetime = parse(datetime_str)
```
Example
```python
np_datetime = parse("2079-02-15") # 2079-02-15 00:00:00
np_datetime = parse("२०७८-०१-१८") # 2078-01-15 00:00:00
np_datetime = parse("2079/02/15") # 2079-02-15 00:00:00
np_datetime = parse("2079-02-15 15:23") # 2079-02-15 15:23:00
np_datetime = parse("2079-02-15 5:23 AM") # 2079-02-15 05:23:00
np_datetime = parse("2079-02-15 5:23 AM") # 2079-02-15 05:23:00
np_datetime = parse("Jestha 15, 2079") # 2079-02-15 00:00:00
```
### strftime() and strptime() Format Codes
| Directive | Meaning | Example |
| --------- | --------------------------------------------------------- | ------------------------------ |
| `%a` | Weekday as locale’s abbreviated name. | Sun, Mon, …, Sat (आइत, सोम, …) |
| `%A` | Weekday as locale’s full name. | Sunday, Monday, …, Saturday |
| `%d` | Day of the month as a zero-padded decimal number. | 01, 02, …, 31 |
| `%-d` | Day of the month as a decimal number. | 1, 2, …, 31 |
| `%B` | Month as locale’s full name. | Baishakh, Jestha, …, Chaitra |
| `%m` | Month as a zero-padded decimal number. | 01, 02, …, 12 |
| `%-m` | Month as a decimal number. | 1, 2, …, 12 |
| `%y` | Year without century as a zero-padded decimal number. | 00, 01, …, 99 |
| `%Y` | Year with century as a decimal number. | 2001, 2078, 2079, …, 2099 |
| `%H` | Hour (24-hour clock) as a zero-padded decimal number. | 00, 01, …, 23 |
| `%-H` | Hour (24-hour clock) as a decimal number. | 0, 1, 2, …, 23 |
| `%I` | Hour (12-hour clock) as a zero-padded decimal number. | 01, 02, …, 12 |
| `%-I` | Hour (12-hour clock) as a decimal number. | 1, 2, …, 12 |
| `%p` | Locale’s equivalent of either AM or PM. | AM, PM (en_US) |
| `%M` | Minute as a zero-padded decimal number. | 00, 01, …, 59 |
| `%-M` | Minute as a decimal number. | 0, 1, 2, …, 59 |
| `%S` | Second as a zero-padded decimal number. | 00, 01, …, 59 |
| `%-S` | Second as a decimal number. | 0, 1, 2, …, 59 |
| `%f` | Microsecond as a decimal number, zero-padded to 6 digits. | 000000, 000001, …, 999999 |
| `%%` | A literal `'%'` character. | % |
---
## Numbers
```python
from nepali import number
```
**convert**
Converts english number to nepali.
```python
np_number = number.convert("1234567890") # १२३४५६७८९०
```
**revert**
Converts english number to nepali.
```python
en_number = number.revert("१२३४५६७८९०") # 1234567890
```
**add_comma**
Adds comma in nepali numbers.
```python
number_text = number.add_comma("1234567890") # 1,23,45,67,890
```
### nepalinumber
`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.
```python
from nepali.number import nepalinumber
```
**Parsing**
```python
a = nepalinumber("१८.२७")
print(a) # 18.27
b = nepalinumber(15)
print(b) # 15
```
**Nepali (Devanagari) output**
```python
a = nepalinumber("18.27")
print(a.str_ne()) # १८.२७
```
**Arithmetic operations**
```python
a = nepalinumber("1")
b = nepalinumber("२")
c = a + b * 3
print(c) # 7
```
---
## Phone Number
```python
from nepali import phone_number
```
**is_valid**
Checks is the given number is a valid nepali phone number.
```python
phone_number.is_valid("9851377890") # True
phone_number.is_valid("+977-142314819") # True
phone_number.is_valid("8251377890") # False
```
**parse**
Parse phone number and returns details of the number.
```python
phone_number.parse("9851377890")
# {'type': 'Mobile', 'number': '9851377890', 'operator': <Operator: Nepal Telecom>}
phone_number.parse("+977-142314819")
# {'type': 'Landline', 'number': '0142314819', 'area_code': '01'}
```
---
## Locations
Provides details of Nepal's Province, District, and Municipality.
```python
from nepali.locations import provinces, districts, municipalities
```
```python
from nepali.locations.utils import get_province, get_district, get_municipality
# Province
get_province(name="Bagmati")
# Bagmati Province
# District
get_district(name="Kathmandu")
# Kathmandu
# Municipality
get_municipality(name="Kathmandu")
# Kathmandu Metropolitan City
# Municipality
get_municipality(name_nepali="विराटनगर")
# Biratnagar Metropolitan City
```
---
## For Django
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).
## Contribution
We appreciate feedback and contribution to this package. To get started please see our [contribution guide](./CONTRIBUTING.md)
Raw data
{
"_id": null,
"home_page": "https://github.com/opensource-nepal/py-nepali",
"name": "nepali",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "nepali date conversion,convert date,nepali date time,python convert date,parse nepali date time",
"author": "opensource-nepal",
"author_email": "aj3sshh@gmail.com, sugatbajracharya49@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f7/d4/b102dbf6ac0ba6f0441ed52c0189cbc541e25c3cd86f6405751bb97e65cb/nepali-1.1.1.tar.gz",
"platform": null,
"description": "# nepali\n\n[![PyPI version](https://badge.fury.io/py/nepali.svg)](https://badge.fury.io/py/nepali)\n[![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)\n[![Downloads](https://img.shields.io/pypi/dm/nepali.svg?maxAge=180)](https://pypi.org/project/nepali/)\n[![codecov](https://codecov.io/gh/opensource-nepal/py-nepali/branch/main/graph/badge.svg?token=PTUHYWCJ4I)](https://codecov.io/gh/opensource-nepal/py-nepali)\n\n`nepali` is a python package containing features that will be useful for Nepali projects.\n\nThe 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.\n\n## Example\n\n```python\nimport datetime\nfrom nepali import phone_number\nfrom nepali.datetime import nepalidate, parser\n\nnepali_datetime = parser.parse('2079-02-15')\n# 2079-02-15 00:00:00\n\ndate = datetime.date(2017, 3, 15)\nnepali_date = nepalidate.from_date(date)\n# 2073-12-02\n\nphone_number.parse(\"+977-9845217789\")\n# {\n# 'type': 'Mobile',\n# 'number': '9845217789',\n# 'operator': <Operator: Nepal Telecom>\n# }\n```\n\n## Requirements\n\n Python >= 3\n\n## Installation\n\n pip install nepali\n\n## Features\n\n1. [Date and Time](#date-and-time)\n - [date_converter](#date_converter)\n - [nepalidate](#nepalidate)\n - [nepalidatetime](#nepalidatetime)\n - [nepalihumanize](#nepalihumanize)\n - [timezone](#timezone)\n - [parse](#parse)\n - [strftime() and strptime() Format Codes](#strftime-and-strptime-format-codes)\n1. [Numbers](#numbers)\n - [nepalinumber](#nepalinumber)\n1. [Phone Number](#phone-number)\n1. [Locations](#locations)\n1. [For Django Template](#for-django-template)\n\n## Date and Time\n\n### date_converter\n\nDate converter module converts english date to nepali and nepali date to english. It doesn't contain any extra functionality.\n\n**Convert English date to Nepali date**\n\n```python\nfrom nepali.date_converter import converter\n\nnp_year, np_month, np_date = converter.english_to_nepali(en_year, en_month, en_date)\n```\n\nExample\n\n```python\nfrom nepali.date_converter import converter\n\nnp_year, np_month, np_date = converter.english_to_nepali(2023, 2, 7)\nprint(np_year, np_month, np_date) # 2079 10 24\n```\n\n**Convert Nepali date to English date**\n\n```python\nfrom nepali.date_converter import converter\n\nen_year, en_month, en_date = converter.nepali_to_english(np_year, np_month, np_date)\n```\n\nExample\n\n```python\nfrom nepali.date_converter import converter\n\nen_year, en_month, en_date = converter.nepali_to_english(2079, 10, 24)\nprint(en_year, en_month, en_date) # 2023 2 7\n```\n\n### nepalidate\n\n**Creating a new nepalidate object**\n\n```python\nfrom nepali.datetime import nepalidate\n\n# nepalidate object with year, month, day\nnp_date = nepalidate(year, month, day)\n\n# nepalidate object with today's date\nnp_date = nepalidate.today()\n\n# parse nepali date\nnp_date = nepalidate.strptime('2078-01-18', format='%Y-%m-%d')\n```\n\n**Getting nepalidate object from python datetime**\n\n```python\n# from date object\nnp_date = nepalidate.from_date(date_obj)\n\n# from datetime object\nnp_date = nepalidate.from_datetime(datetime_obj)\n```\n\n**Attributes and Methods**\n\n```python\nnp_date.year # 2078 (year)\nnp_date.month # 1 (month)\nnp_date.day # 18 (day)\n\nnp_date.to_date() # datetime.date object\nnp_date.to_datetime() # datetime.datetime object\nnp_date.to_nepalidatetime() # nepalidatetime object\n\nnp_date.strftime(\"%Y-%m-%d\") # 2078-01-18\nnp_date.strftime_ne(\"%Y-%m-%d\") # \u0968\u0966\u096d\u096e-\u0966\u0967-\u0967\u096e\n\nnp_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6\n```\n\n### nepalidatetime\n\n**Creating a new nepalidatetime object**\n\n```python\nfrom nepali.datetime import nepalidatetime\n\n# nepalidate object with year, month, day, hour, minute, second\nnp_datetime = nepalidatetime(year, month, day[, hour[, minute[, second]]])\n\n# nepalidate object with current date and time\nnp_datetime = nepalidate.now()\nnp_datetime = nepalidate.today()\n\n# parse nepali datetime\nnp_datetime = nepalidatetime.strptime('2078-01-12 13:12', format='%Y-%m-%d %H:%M')\n```\n\n**Getting nepalidatetime object from python datetime**\n\n```python\n# from date object\nnp_datetime = nepalidatetime.from_date(date_obj)\n\n# from datetime object\nnp_datetime = nepalidatetime.from_datetime(datetime_obj)\n```\n\n**Getting nepalidatetime object from nepalidate**\n\n```python\nnp_datetime = nepalidatetime.from_nepalidate(nepali_date)\n```\n\n**Attributes and Methods**\n\n```python\nnp_date.year # 2078 (year)\nnp_date.month # 1 (month)\nnp_date.day # 18 (day)\nnp_date.hour # 23 (hour)\nnp_date.minute # 59 (minute)\nnp_date.second # 59 (day)\n\nnp_date.to_date() # datetime.date object\nnp_date.to_datetime() # datetime.datetime object\nnp_date.to_nepalidate() # nepalidatetime object\nnp_date.to_time() # nepalitime object (datetime.time compatible)\n\nnp_date.strftime(\"%Y-%m-%d %H:%M\") # 2078-01-18 23:59\nnp_date.strftime_ne(\"%Y-%m-%d %H:%M\") # \u0968\u0966\u096d\u096e-\u0966\u0967-\u0967\u096e \u0968\u0969:\u096b\u096f\n\nnp_date.weekday() # Sunday => 0, Monday => 1, ..., Saturday => 6\n```\n\n**Timedelta support**\n\n```python\n# timedelta addition and subtraction\nnp_datetime - datetime.timedelta(days=3) # returns nepalidatetime\n\n# comparison between two dates\nnp_datetime1 - np_datetime2 # returns timedelta object\nnp_datetime1 < np_datetime2 # returns bool (True/False)\nnp_datetime1 >= datetime.datetime.now() # returns bool (True/False)\n...\n```\n\n### nepalihumanize\n\nReturns readable form of nepali date.\n\n```python\nfrom nepali.datetime import nepalihumanize\n\n\nnepalihumanize(datetime, [threshold, format])\n```\n\nThe `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.\n\nExample\n\n```python\nfrom nepali.datetime import nepalihumanize, nepalidatetime\n\nnp_datetime = nepalidatetime(2079, 10, 5)\noutput = nepalihumanize(np_datetime)\n# output: \u0969 \u092e\u0939\u093f\u0928\u093e \u0905\u0918\u093f\n\noutput = nepalihumanize(np_datetime, threshold=1400)\n# 1400 = 2 * 30 * 24; two months threshold\n# output: \u092e\u093e\u0918 \u0966\u096b, \u0968\u0966\u096d\u096f\n```\n\n### timezone\n\n**NepaliTimeZone**\nYou can use `NepaliTimeZone` directly to your datetime object.\n\n```python\nfrom nepali.timezone import NepaliTimeZone\n\ndatetime.datetime(2018, 8, 12, 16, 23, tzinfo=NepaliTimeZone())\n```\n\n**now**\nReturns current datetime object with timezone\n\n```python\nfrom nepali import timezone\n\ntimezone.now()\n```\n\n`datetime.now()` vs `timezone.now()`:\n`datetime.now()` doesn't contain timezone, but `timezone.now()` will contain timezone of the system.\n\n**utc_now**\nReturns current UTC datetime object (with timezone UTC)\n\n```python\nfrom nepali import timezone\n\ntimezone.utc_now()\n```\n\n### parse\n\nParses date with commonly used date formats. Auto detects date format. If you are sure about the format, please use `strptime`.\n\n```python\nfrom nepali.datetime.parser import parse\n\nnp_datetime = parse(datetime_str)\n```\n\nExample\n\n```python\nnp_datetime = parse(\"2079-02-15\") # 2079-02-15 00:00:00\nnp_datetime = parse(\"\u0968\u0966\u096d\u096e-\u0966\u0967-\u0967\u096e\") # 2078-01-15 00:00:00\nnp_datetime = parse(\"2079/02/15\") # 2079-02-15 00:00:00\nnp_datetime = parse(\"2079-02-15 15:23\") # 2079-02-15 15:23:00\nnp_datetime = parse(\"2079-02-15 5:23 AM\") # 2079-02-15 05:23:00\nnp_datetime = parse(\"2079-02-15 5:23 AM\") # 2079-02-15 05:23:00\nnp_datetime = parse(\"Jestha 15, 2079\") # 2079-02-15 00:00:00\n\n```\n\n### strftime() and strptime() Format Codes\n\n| Directive | Meaning | Example |\n| --------- | --------------------------------------------------------- | ------------------------------ |\n| `%a` | Weekday as locale\u2019s abbreviated name. | Sun, Mon, \u2026, Sat (\u0906\u0907\u0924, \u0938\u094b\u092e, \u2026) |\n| `%A` | Weekday as locale\u2019s full name. | Sunday, Monday, \u2026, Saturday |\n| `%d` | Day of the month as a zero-padded decimal number. | 01, 02, \u2026, 31 |\n| `%-d` | Day of the month as a decimal number. | 1, 2, \u2026, 31 |\n| `%B` | Month as locale\u2019s full name. | Baishakh, Jestha, \u2026, Chaitra |\n| `%m` | Month as a zero-padded decimal number. | 01, 02, \u2026, 12 |\n| `%-m` | Month as a decimal number. | 1, 2, \u2026, 12 |\n| `%y` | Year without century as a zero-padded decimal number. | 00, 01, \u2026, 99 |\n| `%Y` | Year with century as a decimal number. | 2001, 2078, 2079, \u2026, 2099 |\n| `%H` | Hour (24-hour clock) as a zero-padded decimal number. | 00, 01, \u2026, 23 |\n| `%-H` | Hour (24-hour clock) as a decimal number. | 0, 1, 2, \u2026, 23 |\n| `%I` | Hour (12-hour clock) as a zero-padded decimal number. | 01, 02, \u2026, 12 |\n| `%-I` | Hour (12-hour clock) as a decimal number. | 1, 2, \u2026, 12 |\n| `%p` | Locale\u2019s equivalent of either AM or PM. | AM, PM (en_US) |\n| `%M` | Minute as a zero-padded decimal number. | 00, 01, \u2026, 59 |\n| `%-M` | Minute as a decimal number. | 0, 1, 2, \u2026, 59 |\n| `%S` | Second as a zero-padded decimal number. | 00, 01, \u2026, 59 |\n| `%-S` | Second as a decimal number. | 0, 1, 2, \u2026, 59 |\n| `%f` | Microsecond as a decimal number, zero-padded to 6 digits. | 000000, 000001, \u2026, 999999 |\n| `%%` | A literal `'%'` character. | % |\n\n---\n\n## Numbers\n\n```python\nfrom nepali import number\n```\n\n**convert**\nConverts english number to nepali.\n\n```python\nnp_number = number.convert(\"1234567890\") # \u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u0966\n```\n\n**revert**\nConverts english number to nepali.\n\n```python\nen_number = number.revert(\"\u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f\u0966\") # 1234567890\n```\n\n**add_comma**\nAdds comma in nepali numbers.\n\n```python\nnumber_text = number.add_comma(\"1234567890\") # 1,23,45,67,890\n```\n\n### nepalinumber\n`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.\n\n```python\nfrom nepali.number import nepalinumber\n```\n\n**Parsing**\n```python\na = nepalinumber(\"\u0967\u096e.\u0968\u096d\")\nprint(a) # 18.27\n\nb = nepalinumber(15)\nprint(b) # 15\n```\n\n**Nepali (Devanagari) output**\n```python\na = nepalinumber(\"18.27\")\nprint(a.str_ne()) # \u0967\u096e.\u0968\u096d\n```\n\n**Arithmetic operations**\n```python\na = nepalinumber(\"1\")\nb = nepalinumber(\"\u0968\")\nc = a + b * 3\nprint(c) # 7\n```\n---\n\n## Phone Number\n\n```python\nfrom nepali import phone_number\n```\n\n**is_valid**\nChecks is the given number is a valid nepali phone number.\n\n```python\nphone_number.is_valid(\"9851377890\") # True\nphone_number.is_valid(\"+977-142314819\") # True\n\nphone_number.is_valid(\"8251377890\") # False\n```\n\n**parse**\nParse phone number and returns details of the number.\n\n```python\nphone_number.parse(\"9851377890\")\n# {'type': 'Mobile', 'number': '9851377890', 'operator': <Operator: Nepal Telecom>}\n\nphone_number.parse(\"+977-142314819\")\n# {'type': 'Landline', 'number': '0142314819', 'area_code': '01'}\n```\n\n---\n\n## Locations\n\nProvides details of Nepal's Province, District, and Municipality.\n\n```python\nfrom nepali.locations import provinces, districts, municipalities\n```\n\n```python\nfrom nepali.locations.utils import get_province, get_district, get_municipality\n\n# Province\nget_province(name=\"Bagmati\")\n# Bagmati Province\n\n# District\nget_district(name=\"Kathmandu\")\n# Kathmandu\n\n# Municipality\nget_municipality(name=\"Kathmandu\")\n# Kathmandu Metropolitan City\n\n# Municipality\nget_municipality(name_nepali=\"\u0935\u093f\u0930\u093e\u091f\u0928\u0917\u0930\")\n# Biratnagar Metropolitan City\n```\n\n---\n\n## For Django\n\nWe 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).\n\n## Contribution\n\nWe appreciate feedback and contribution to this package. To get started please see our [contribution guide](./CONTRIBUTING.md)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "nepalidatetime compatible with python's datetime feature. Converting nepali date to english, parsing nepali datetime, nepali timezone, and timedelta support in nepali datetime",
"version": "1.1.1",
"project_urls": {
"Changelog": "https://github.com/opensource-nepal/py-nepali/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/opensource-nepal/py-nepali",
"Source": "https://github.com/opensource-nepal/py-nepali"
},
"split_keywords": [
"nepali date conversion",
"convert date",
"nepali date time",
"python convert date",
"parse nepali date time"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e25ae43304fb3ef16398712ef71160cf3440a33bd20b2f49f254cbe6dda67a39",
"md5": "c2f4e71f5f976e527a65f0213783976b",
"sha256": "08aa6cb1b5dc9174e4b7f730e605dd1d0d2daaa90579d01d0786f0040035b0da"
},
"downloads": -1,
"filename": "nepali-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c2f4e71f5f976e527a65f0213783976b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 69299,
"upload_time": "2024-03-13T14:50:15",
"upload_time_iso_8601": "2024-03-13T14:50:15.017877Z",
"url": "https://files.pythonhosted.org/packages/e2/5a/e43304fb3ef16398712ef71160cf3440a33bd20b2f49f254cbe6dda67a39/nepali-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f7d4b102dbf6ac0ba6f0441ed52c0189cbc541e25c3cd86f6405751bb97e65cb",
"md5": "72ebe7ed3b16d73839dc90ea9286d40b",
"sha256": "3e0cdf469432bcd0031e9114f92c75aea13a88492299a30af88dc0db0934eeee"
},
"downloads": -1,
"filename": "nepali-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "72ebe7ed3b16d73839dc90ea9286d40b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 63356,
"upload_time": "2024-03-13T14:50:17",
"upload_time_iso_8601": "2024-03-13T14:50:17.233847Z",
"url": "https://files.pythonhosted.org/packages/f7/d4/b102dbf6ac0ba6f0441ed52c0189cbc541e25c3cd86f6405751bb97e65cb/nepali-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-13 14:50:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "opensource-nepal",
"github_project": "py-nepali",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "nepali"
}