Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A module for returning a human readable value for a time between two dates. Inspired by whenWasThat() function from BMC Discovery.

License

NotificationsYou must be signed in to change notification settings

codefitz/WhenWasThat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python module for returning a human readable value for the time between two specified datetime objects. Inspired by whenWasThat() function from BMC Discovery.

Properties

PropertyDetails
microsecondsOutput the total number of microseconds between two datetime objects
secondsOutput the total number of seconds between two datetime objects
minutesOutput the total number of minutes between two datetime objects
hoursOutput the total number of hours between two datetime objects
daysOutput the total number of days between two datetime objects
weeksOutput the total number of weeks between two datetime objects
monthsOutput the total number of months between two datetime objects
yearsOutput the total number of years between two datetime objects
naturalOutput an approximate number of seconds, minutes, hours, days, weeks, months or years between two datetime objects

Usage Examples

Retrieve number of days between two dates

>>>importimportdatetimeasdt>>>fromWhenWasThatimportwhen>>>first_date=dt.datetime(2006,10,27,11,59,32,343001)>>>last_date=dt.datetime(2016,9,30,20,21,43,561783)>>>when(first_date,last_date).days3626.348740958125

Output a natural approximation of the time between two dates

>>>first_date=dt.datetime(2006,10,27,11,59,32,343001)>>>last_date=dt.datetime(2016,9,30,20,21,43,561783)>>>when(first_date,last_date).naturalApproximately9.9yearsago

Last date is not required (module will calculate fromdatetime.now())

>>>time_then=dt.datetime(2020,3,23,0,1,1,1)>>>when(time_then).weeks75.20358385298611>>>when(time_then).naturalApproximately17.5monthsago

How many days since the Titanic sunk?

>>>dt.datetime.now()datetime.datetime(2021,8,31,10,20,59,979468)>>>titanic=dt.datetime(1912,4,15,2,20,0,0)>>>print("The Titanic sunk %s days ago."%round(when(titanic).days))TheTitanicsunk39950daysago.

Releases

VersionSummaryKnown IssuesFixed
Alpha-0.0.1Alpha release.
0.1.0Released to PyPi

About

A module for returning a human readable value for a time between two dates. Inspired by whenWasThat() function from BMC Discovery.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp