Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

omushpapa/daterelate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DateRelate

Travis-CI Codacy Badge Issues

Relate two dates to each other easily (e.g. today to tomorrow, new year to today)

Usage

$ pip install daterelate
  • Relate using datetime objects
>>> from daterelate.daterelate import relate
>>> from datetime import datetime
>>>
>>> tomorrow  = datetime.strptime('12-12-2017', '%d-%m-%Y')
>>> next_occurrence = datetime.strptime('2-02-2018', '%d-%m-%Y')
>>>
>>> relate(next_occurrence, tomorrow)	# relate next_occurrence to tomorrow
'52 days to come'
>>>
>>> relate(next_occurrence, tomorrow, future='remaining')
'52 days remaining'
  • Relate using string values
>>> from daterelate.daterelate import relate_from_string
>>>
>>> tomorrow  = datetime.strptime('12-12-2017', '%d-%m-%Y')
>>> next_occurrence = datetime.strptime('2-02-2018', '%d-%m-%Y')
>>>
>>> relate_from_string('12/12/2017')	# relate next_occurrence to current date, return value depends on current date
>>>
>>> relate_from_string('12/12/2017', '2/02/2018', future='before the eclipse')
'52 days before the eclipse'

More

... to be added

etc

Distributed under MIT

About

Relate dates in human readable form. See https://github.com/jmoiron/humanize which has more functionality

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published