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 81 0
Python Pendulum Limitations in DJANGO 108 0
Python Pendulum Limitations in MYSQLCLIENT 90 0
Python Pendulum Limitations in SQLITE3 93 0
Python Pendulum Testing 2 96 0
Python Pendulum Testing 112 0
Python Pendulum Range 109 0
Python Pendulum Period 3 107 0
Python Pendulum Period 2 99 0
Python Pendulum Period 98 0
Python Pendulum Properties and Duration Methods 2 96 0
Python Pendulum Properties and Duration Methods 104 0
Python Pendulum Instantiation 105 0
Python Pendulum Duration 102 0
Python Pendulum TImezone usage 2 91 0
Python Pendulum Timezone usage 89 0
Python Pendulum Switching Timezones 97 0
Python Pendulum Shifting Time to Transition 109 0
Python Pendulum Normalization 108 0
Python Pendulum Modifiers 2 109 0
Python Pendulum Modifiers 104 0
Python Pendulum Difference for Humans 2 139 0
Python Pendulum Difference for Humans 111 0
Python Pendulum Difference 113 0
Python pendulum Substraction 126 0
Pyhton pendulum Addition 121 0
Python pendulum Comapaison part 2 115 0
Python Pendulum Comparison 116 0
Python Pendulum Localized Formats and Escaping characteristics 115 0
Python pendulum Tokens 121 0
Python pendulum Formatter 114 0
Python pendulum Common Formats 120 0
Python pendulum String Formatting 121 0
Python pendulum Fluent helpers 2 113 0
Python pendulum Fluent helpers 104 0
Python pendulum Attributes and Properties 108 0
Python pendulum Localization 133 118
Python pendulum parsing 2 129 23
Python pendulum Parsing 1 136 61
Python pendulum 2 144 57
Python pendulum basics 134 9
python library Pendulum 134 33
python winsound.SND_PURGE and winsound.SND_WAIT 147 5
Python winsound.SND_NOSTOP 173 1
Python winsound.SND_NODEFAULT 156 1
python winsound.SND_ASYNC not excecuting problem 162 2
Python winsound functions 181 3
python winsound.SND_ALIAS 188 1
Python winsound.MessageBeep() 201 1
Python winsound basic introduction 238 1

Comments