课程: Python Essential Libraries

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Date calculation and comparison

Date calculation and comparison

- [Instructor] One of the things that many developers dread the most when having to work with dates are calculations and comparisons, and that's because there's a lot of edge cases to have to handle. I mean, think about leap years, and months having different number of days, and properly handling the rollover when you add a number of hours to an existing date, so that causes the day to change, and so on. And Pendulum handles many of these common cases for you with simple to use functions. So let's try some of them out. So in your editor, let's go ahead and open up the calculation_start file. And you can see I have already imported the Pendulum library and I've created two datetime instances, and I'm also printing out the Original Dates, so that we can see them in the output and compare them. So let's start with adding and subtracting time. To add and subtract time on a datetime instance, Pendulum provides the add and…

内容