Https://pypi.python.org/pypi/pendulum
One of the great advantages of pendulum is that it replaces the Python datetime class in-line, and it can easily be integrated into existing code and invoked only when needed. The author carefully tuned the time zone to ensure that the time zone is accurate and that each instance is sensitive to time zones, using UTC by default. There is also an extended timedelta that makes datetime calculations easier.
Unlike an existing library, it provides an API for predictable behavior, so you know what happens later. If you are developing a complex project using DateTimes, this library will make it easier for you! To learn more, check out the documentation.
>>>ImportPendulum>>> Now_in_paris = Pendulum.now ('Europe/paris')>>>Now_in_paris'2016-07-04t00:49:58.502116+02:00'#Seamless timezone Switching>>> Now_in_paris.in_timezone ('UTC')'2016-07-03t22:49:58.502116+00:00'>>> tomorrow = Pendulum.now (). Add (Days=1)>>> Last_week = Pendulum.now (). Subtract (Weeks=1)>>>ifPendulum.now (). Is_weekend (): ...Print('party!')'party!'>>> past = Pendulum.now (). Subtract (minutes=2)>>>Past.diff_for_humans ()>>>'2 minutes ago'>>> Delta = past-Last_week>>>delta.hours23>>> Delta.in_words (locale='en')'6 days hours minutes'#Proper handling of datetime normalization>>> pendulum.create (2013, 3, 31, 2, 30, 0, 0,'Europe/paris')'2013-03-31t03:30:00+02:00' #does not exist (skipped time)#Proper handling of DST transitions>>> Just_before = Pendulum.create (2013, 3, 31, 1, 59, 59, 999999,'Europe/paris')'2013-03-31t01:59:59.999999+01:00'>>> Just_before.add (Microseconds=1)'2013-03-31t03:00:00+02:00'
Python base ===pendulum ' python datetimes made easy. '