Skip to content

Latest commit

 

History

History
82 lines (59 loc) · 2.05 KB

README.md

File metadata and controls

82 lines (59 loc) · 2.05 KB

past_date2word

past_date2word is library helps you to convert the past date to text

PyPI - Python Version PyPI License Code style: black past_date2word-test

RequirementsInstallationExamplesLicense


Requirements


Installation

Use PyPi to install past_date2word.

pip3 install past_date2word

Example

from past_date2word import past_date2word
from datetime import datetime, timedelta

# Less than one second of time
date = datetime.now() - timedelta(seconds=1)
print(past_date2word(date)) # "1 second ago"

# Less than 23 seconds of time
date = datetime.now() - timedelta(seconds=23)
print(past_date2word(date)) # "23 seconds ago"

# Less than 1 week and 1 day of time
date = datetime.now() - timedelta(weeks=1, days=1)
print(past_date2word(date)) #"1 week and 1 day ago"

# Less than 2 weeks and 4 days of time
date = datetime.now() - timedelta(weeks=2, days=4)
print(past_date2word(date)) #"2 weeks and 4 days ago"

# And more try it

License

GPLv3