pychronic
Introduction
A natural language date parser in Python. Inspired from Ruby's chronic.
Installation
pip install pychronic
Usage:
- Datetime To Natural Langauge
from pychronic.utils import to_natural_time
from datetime import datetime, timedelta, date
>>> to_natural_time(datetime.now())
{'day': 'today', 'time': '10:56 PM', 'month': 'September', 'year': 2019, 'day_of_week': 'Friday'}
>>> to_natural_time(datetime.now() - timedelta(days=1))
{'day': 'yesterday', 'time': '10:56 PM', 'month': 'September', 'year': 2019, 'day_of_week': 'Thursday'}
>>> to_natural_time(datetime.now() + timedelta(days=1))
{'day': 'tomorrow', 'time': '10:57 PM', 'month': 'September', 'year': 2019, 'day_of_week': 'Saturday'}
>>> to_natural_time(datetime(year=2019, month=1, day=1, hour=1, minute=0, second=0))
{'day': '1st', 'time': '01:00 AM', 'month': 'January', 'year': 2019, 'day_of_week': 'Tuesday'}
- Highlight datetime in text
from pychronic.utils import highlight_from_text
>>> highlight_from_text("Tournament will commence on 12:30 PM on 23rd May and end on 25th aug")
{'input': ['Tournament', 'will', 'commence', 'on', '12:30', 'PM', 'on', '23rd', 'May', 'and', 'end', 'on', '25th', 'aug'], 'matched_pattern': [{'from_index': 4, 'to_index': 8, 'parsed_value': datetime.datetime(2019, 5, 23, 12, 30)}, {'fro
m_index': 12, 'to_index': 13, 'parsed_value': datetime.date(2019, 8, 25)}]}
>>> highlight_from_text("Tournament will commence on 11:30 PM on 23rd May and end on 25th aug")
{'input': ['Tournament', 'will', 'commence', 'on', '11:30', 'PM', 'on', '23rd', 'May', 'and', 'end', 'on', '25th', 'aug'], 'matched_pattern': [{'from_index': 4, 'to_index': 8, 'parsed_value': datetime.datetime(2019, 5, 23, 23, 30)}, {'fro
m_index': 12, 'to_index': 13, 'parsed_value': datetime.date(2019, 8, 25)}]}
>>> highlight_from_text("Today is 25th of december")
{'input': ['Today', 'is', '25th', 'of', 'december'], 'matched_pattern': [{'from_index': 2, 'to_index': 4, 'parsed_value': datetime.date(2019, 12, 25)}]}
>>> highlight_from_text("Results are on 23-may-2019 or 24-may-2019")
{'input': ['Results', 'are', 'on', '23-may-2019', 'or', '24-may-2019'], 'matched_pattern': [{'from_index': 3, 'to_index': 3, 'parsed_value': datetime.date(2019, 5, 23)}, {'from_index': 5, 'to_index': 5, 'parsed_value': datetime.date(2019,
5, 24)}]}
Contributing
Fork and pull request.
Contributors
Metadata
Release files for pychronic 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pychronic-0.0.14.tar.gz | 6.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pychronic-0.0.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / pychronic-0.0.14.tar.gz
| Download URL | pychronic-0.0.14.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07dc6bc7a7e300c54bca6be2f0ef27cf9ba0daff4d4e01759443da1fc6b2fa45
|
|
BLAKE2b-256 checksum How to use checksums |
1c4ac65e15e2e49a349a75b9a20257a9c409d43489eb2783726d883de55a3b4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.10
|
Release files / pychronic-0.0.14-py3-none-any.whl
| Download URL | pychronic-0.0.14-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01abe959518c2cb015cb9dffbc2c5bfcbd166bcd9e9bb0606c1004c6641d240d
|
|
BLAKE2b-256 checksum How to use checksums |
432c905c94b3ddca2feff6f8463528f934e040339cb680bdb7e5917d3c325c43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.10
|
Security for pychronic 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.