Python Pendulum Shifting Time to Transition














































Python Pendulum Shifting Time to Transition



              Shifting Time to Transition


So, what happens when you add time to a DateTime instance and stumble upon a transition time? Well, the pendulum, provided with the context of the previous instance, will adopt the proper behavior and apply the transition accordingly.


      #CODE

import pendulum

dt = pendulum.datetime(2013, 3, 31, 1, 59, 59, 999999,
                           tz='Europe/Paris')
print(dt)

dt = dt.add(microseconds=1)
print(dt)

print(dt.subtract(microseconds=1))

dt = pendulum.datetime(2013, 10, 27, 2, 59, 59, tz='Europe/Paris',dst_rule=pendulum.PRE_TRANSITION)
print(dt)

dt = dt.add(microseconds=1)
print(dt)

dt = dt.subtract(microseconds=1)
print(dt)



    #OUTPUT

2013-03-31T01:59:59.999999+01:00
2013-03-31T03:00:00+02:00
2013-03-31T01:59:59.999999+01:00
2013-10-27T02:59:59+02:00
2013-10-27T02:59:59.000001+02:00
2013-10-27T02:59:59+02:00


More Articles of Anmol Agrawal:

Name Views Likes
Python Pendulum Why to use Pendulum 161 0
Python Pendulum Limitations in DJANGO 240 0
Python Pendulum Limitations in MYSQLCLIENT 160 0
Python Pendulum Limitations in SQLITE3 171 0
Python Pendulum Testing 2 165 0
Python Pendulum Testing 198 0
Python Pendulum Range 199 0
Python Pendulum Period 3 172 0
Python Pendulum Period 2 165 0
Python Pendulum Period 166 0
Python Pendulum Properties and Duration Methods 2 172 0
Python Pendulum Properties and Duration Methods 170 0
Python Pendulum Instantiation 169 0
Python Pendulum Duration 157 0
Python Pendulum TImezone usage 2 162 0
Python Pendulum Timezone usage 178 0
Python Pendulum Switching Timezones 160 0
Python Pendulum Shifting Time to Transition 179 0
Python Pendulum Normalization 177 0
Python Pendulum Modifiers 2 178 0
Python Pendulum Modifiers 174 0
Python Pendulum Difference for Humans 2 202 0
Python Pendulum Difference for Humans 196 0
Python Pendulum Difference 226 0
Python pendulum Substraction 189 0
Pyhton pendulum Addition 192 0
Python pendulum Comapaison part 2 197 0
Python Pendulum Comparison 200 0
Python Pendulum Localized Formats and Escaping characteristics 182 0
Python pendulum Tokens 181 0
Python pendulum Formatter 190 0
Python pendulum Common Formats 189 0
Python pendulum String Formatting 199 0
Python pendulum Fluent helpers 2 173 0
Python pendulum Fluent helpers 170 0
Python pendulum Attributes and Properties 197 0
Python pendulum Localization 210 118
Python pendulum parsing 2 203 23
Python pendulum Parsing 1 210 61
Python pendulum 2 231 57
Python pendulum basics 204 9
python library Pendulum 206 33
python winsound.SND_PURGE and winsound.SND_WAIT 247 5
Python winsound.SND_NOSTOP 256 1
Python winsound.SND_NODEFAULT 219 1
python winsound.SND_ASYNC not excecuting problem 224 2
Python winsound functions 274 3
python winsound.SND_ALIAS 258 1
Python winsound.MessageBeep() 391 1
Python winsound basic introduction 359 1

Comments