22########
33
44.. image :: https://travis-ci.org/sdispater/pendulum.png
5- :alt: Orator Build status
5+ :alt: Pendulum Build status
66 :target: https://travis-ci.org/sdispater/pendulum
77
88Python datetimes made easy.
@@ -17,6 +17,8 @@ Supports Python **2.7+** and **3.2+**.
1717 >> > now_in_paris = pendulum.now(' Europe/Paris' )
1818 >> > now_in_paris
1919 ' 2016-07-04T00:49:58.502116+02:00'
20+
21+ # Seamless timezone switching
2022 >> > now_in_paris.in_timezone(' UTC' )
2123 ' 2016-07-03T22:49:58.502116+00:00'
2224
@@ -37,6 +39,16 @@ Supports Python **2.7+** and **3.2+**.
3739 >> > delta.in_words(locale = ' en' )
3840 ' 6 days 23 hours 58 minutes'
3941
42+ # Proper handling of datetime normalization
43+ >> > pendulum.create(2013 , 3 , 31 , 2 , 30 , 0 , 0 , ' Europe/Paris' )
44+ ' 2013-03-31T03:30:00+02:00' # 2:30 does not exist (Skipped time)
45+
46+ # Proper handling of dst transitions
47+ >> > just_before = pendulum.create(2013 , 3 , 31 , 1 , 59 , 59 , 999999 , ' Europe/Paris' )
48+ ' 2013-03-31T01:59:59.999999+01:00'
49+ >> > just_before.add(microseconds = 1 )
50+ ' 2013-03-31T03:00:00+02:00'
51+
4052
4153 Why Pendulum?
4254=============
@@ -90,13 +102,16 @@ and it will try its best to return something while silently failing to handle so
90102 # Working with DST
91103 just_before = arrow.Arrow(2013 , 3 , 31 , 1 , 59 , 59 , 999999 , ' Europe/Paris' )
92104 just_after = just_before.replace(microseconds = 1 )
105+ ' 2013-03-31T02:00:00+02:00'
106+ # Should be 2013-03-31T03:00:00+02:00
93107
94108 (just_after.to(' utc' ) - just_before.to(' utc' )).total_seconds()
95109 - 3599.999999
96110 # Should be 1e-06
97111
98112 just_before = pendulum.create(2013 , 3 , 31 , 1 , 59 , 59 , 999999 , ' Europe/Paris' )
99113 just_after = just_before.add(microseconds = 1 )
114+ ' 2013-03-31T03:00:00+02:00'
100115
101116 (just_after.in_timezone(' utc' ) - just_before.in_timezone(' utc' )).total_seconds()
102117 1e-06
0 commit comments