Python Pendulum Modifiers 2














































Python Pendulum Modifiers 2



                               modifiers

In the previous article, I left some parts of the modifiers in this article I covered it.

     #CODE

import pendulum

dt = pendulum.datetime(2022, 1, 31, 12, 0, 0)

print(dt.start_of('week'))

print(dt.day_of_week == pendulum.MONDAY)

print(dt.end_of('week'))

print(dt.day_of_week == pendulum.SUNDAY)

print(dt.next(pendulum.WEDNESDAY))

print(dt.day_of_week == pendulum.WEDNESDAY)

dt = pendulum.datetime(2022, 1, 1, 12, 0, 0)

print(dt.next())

print(dt.next(keep_time=True))

dt = pendulum.datetime(2022, 1, 31, 12, 0, 0)

print(dt.previous(pendulum.WEDNESDAY))

print(dt.day_of_week == pendulum.WEDNESDAY)

dt = pendulum.datetime(2022, 1, 1, 12, 0, 0)

print(dt.previous())

print(dt.previous(keep_time=True))

start = pendulum.datetime(2024, 1, 1)

end = pendulum.datetime(2024, 1, 30)

print(start.average(end))



# others that are defined that are similar
# and tha accept month, quarter and year units
# first_of(), last_of(), nth_of()


     #OUTPUT

2022-01-31T00:00:00+00:00
True
2022-02-06T23:59:59.999999+00:00
False
2022-02-02T00:00:00+00:00
False
2022-01-08T00:00:00+00:00
2022-01-08T12:00:00+00:00
2022-01-26T00:00:00+00:00
False
2021-12-25T00:00:00+00:00
2021-12-25T12:00:00+00:00
2024-01-15T12:00:00+00:00

More Articles of Anmol Agrawal:

Name Views Likes
Python Pendulum Why to use Pendulum 176 0
Python Pendulum Limitations in DJANGO 262 0
Python Pendulum Limitations in MYSQLCLIENT 182 0
Python Pendulum Limitations in SQLITE3 197 0
Python Pendulum Testing 2 182 0
Python Pendulum Testing 215 0
Python Pendulum Range 220 0
Python Pendulum Period 3 185 0
Python Pendulum Period 2 184 0
Python Pendulum Period 187 0
Python Pendulum Properties and Duration Methods 2 185 0
Python Pendulum Properties and Duration Methods 187 0
Python Pendulum Instantiation 185 0
Python Pendulum Duration 169 0
Python Pendulum TImezone usage 2 180 0
Python Pendulum Timezone usage 191 0
Python Pendulum Switching Timezones 177 0
Python Pendulum Shifting Time to Transition 207 0
Python Pendulum Normalization 192 0
Python Pendulum Modifiers 2 192 0
Python Pendulum Modifiers 190 0
Python Pendulum Difference for Humans 2 211 0
Python Pendulum Difference for Humans 230 0
Python Pendulum Difference 265 0
Python pendulum Substraction 209 0
Pyhton pendulum Addition 215 0
Python pendulum Comapaison part 2 209 0
Python Pendulum Comparison 217 0
Python Pendulum Localized Formats and Escaping characteristics 196 0
Python pendulum Tokens 198 0
Python pendulum Formatter 208 0
Python pendulum Common Formats 201 0
Python pendulum String Formatting 217 0
Python pendulum Fluent helpers 2 185 0
Python pendulum Fluent helpers 186 0
Python pendulum Attributes and Properties 218 0
Python pendulum Localization 230 118
Python pendulum parsing 2 221 23
Python pendulum Parsing 1 230 61
Python pendulum 2 247 57
Python pendulum basics 220 9
python library Pendulum 220 33
python winsound.SND_PURGE and winsound.SND_WAIT 263 5
Python winsound.SND_NOSTOP 276 1
Python winsound.SND_NODEFAULT 234 1
python winsound.SND_ASYNC not excecuting problem 244 2
Python winsound functions 295 3
python winsound.SND_ALIAS 286 1
Python winsound.MessageBeep() 449 1
Python winsound basic introduction 409 1

Comments