Python Pendulum Comparison














































Python Pendulum Comparison



                                       COmparison

Simple comparison is offered up via the basic operators. Remember that the comparison is made in the UTC timezone so things aren't always as they seem.

    #CODE


import pendulum
>>> first = pendulum.datetime(2012, 9, 5, 23, 26, 11, 0, tz='America/Toronto')
>>> second = pendulum.datetime(2012, 9, 5, 20, 26, 11, 0, tz='America/Vancouver')
>>> first.to_datetime_string()
'2012-09-05 23:26:11'
>>> first.timezone_name
'America/Toronto'
>>> second.to_datetime_string()
'2012-09-05 20:26:11'
>>> second.timezone_name
'America/Vancouver'
>>> first == second #by comparing
True
>>> first != second
False
>>> first > second
False
>>> first >= second
True
>>> first < second
False
>>> first <= second
True
>>> first = first.on(2012, 1, 1).at(0, 0, 0)
>>> second = second.on(2012, 1, 1).at(0, 0, 0)
# tz is still America/Vancouver for second
>>> first == second
False
>>> first != second
True
>>> first > second
False
>>> first >= second
False
>>> first < second
True
>>> first <= second
True






More Articles of Anmol Agrawal:

Name Views Likes
Python Pendulum Why to use Pendulum 199 0
Python Pendulum Limitations in DJANGO 294 0
Python Pendulum Limitations in MYSQLCLIENT 203 0
Python Pendulum Limitations in SQLITE3 220 0
Python Pendulum Testing 2 208 0
Python Pendulum Testing 241 0
Python Pendulum Range 255 0
Python Pendulum Period 3 207 0
Python Pendulum Period 2 203 0
Python Pendulum Period 211 0
Python Pendulum Properties and Duration Methods 2 207 0
Python Pendulum Properties and Duration Methods 212 0
Python Pendulum Instantiation 206 0
Python Pendulum Duration 191 0
Python Pendulum TImezone usage 2 204 0
Python Pendulum Timezone usage 210 0
Python Pendulum Switching Timezones 201 0
Python Pendulum Shifting Time to Transition 229 0
Python Pendulum Normalization 217 0
Python Pendulum Modifiers 2 212 0
Python Pendulum Modifiers 217 0
Python Pendulum Difference for Humans 2 230 0
Python Pendulum Difference for Humans 253 0
Python Pendulum Difference 305 0
Python pendulum Substraction 231 0
Pyhton pendulum Addition 242 0
Python pendulum Comapaison part 2 232 0
Python Pendulum Comparison 246 0
Python Pendulum Localized Formats and Escaping characteristics 219 0
Python pendulum Tokens 222 0
Python pendulum Formatter 233 0
Python pendulum Common Formats 221 0
Python pendulum String Formatting 245 0
Python pendulum Fluent helpers 2 209 0
Python pendulum Fluent helpers 211 0
Python pendulum Attributes and Properties 245 0
Python pendulum Localization 256 118
Python pendulum parsing 2 248 23
Python pendulum Parsing 1 254 61
Python pendulum 2 270 57
Python pendulum basics 243 9
python library Pendulum 246 33
python winsound.SND_PURGE and winsound.SND_WAIT 286 5
Python winsound.SND_NOSTOP 298 1
Python winsound.SND_NODEFAULT 262 1
python winsound.SND_ASYNC not excecuting problem 264 2
Python winsound functions 323 3
python winsound.SND_ALIAS 310 1
Python winsound.MessageBeep() 494 1
Python winsound basic introduction 469 1

Comments