pendulum
is a prevalent python library in my company. For example, if I want to get the time of the previous Monday, it could be written:
pendulum.today("US/Pacific").previous(pendulum.MONDAY) # return type "pendulum.datetime.DateTime`
But this will return a class of pendulum.datetime.DateTime
. What if I wish Date
instead of pendulum.datetime.DataTime
? Actually, the pendulum.datetime.DateTime
inherited from datetime.datetime
so we can use .date()
:
pendulum.today("US/Pacific").previous(pendulum.MONDAY).date() # return type "pendulum.datetime.Date`