Skip to content

Jerakin/humantime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Humantime

"Close enough" time that makes sense when reading it.

Port of date-fns.formatDistance

There are two methods time_between and time_since.

time_between takes two datetime objects and returns the time elapsed.

time_since takes a single datetime object and calculates the difference between that and now.

Usage

from datetime import datetime

import humantime
jan_1st = datetime(year=2015, month=1, day=1)
seconds_later = datetime(year=2015, month=1, day=1, second=15)

print(humantime.time_between(jan_1st, seconds_later))
# "less than a minute"

Releases

No releases published

Packages

No packages published

Languages