 So, good morning, everyone. Today, we are here to talk about the troublesome journey that we had been dealing with time. So, the topic is time ADC with pendulum. So, before we begin, let's get to know some more about us. My name is Yodhra Aditya and presenting alongside me is Aberdeen C. We both work at the USD currently and we are working on a travel platform called Strollbike that lets you travel across the world without the fuss and it just brings everything that you want in travel. Into your palms, actually. So, and we also volunteer at Kerala Police Cyber Dom, which is a local law enforcement agency, and we created a tool called, we're working and collaborating with everybody with our tool called Grapnel that lets you surveil the dark web and it'll probably be launched globally pretty soon. So, you might also get to experience that. So, let's get to the slides. So, it's time to begin. And so, what is time. If you have seen the show called genius by National Geographic, you might have heard about this exact quote that time is but a stubborn illusion by Einstein itself. So, this is an interesting quote to us was it unravels a lot of mysteries that you might encounter with time. When you are programming, especially in pipes. So, I'll hand over the slide to I've been into present and talk more about time. Thank you, Jordan. So, time. There are many definitions for time. And scientists say something like time is relative time. They have a definition of time standard unit of time, and we program programmers ourselves have another definition we define time as a number of seconds that have laps since January one of the midnight. It's basically what's known as Unix epoch. So, is the unique epoch Unix timestamp the standard that we all follow, or is it not. How do we store time we actually store time in many different formats like GMT local time UTC, and even many more formats that each region adapts to their own each developer adapts to their own standards. They follow and even using a single time zone time format we have to deal with intricacies like daylight saving time and other changes that happen politically that causes developers. A lot of frustrations because there are a lot of nitty gritty inconsistency that happens throughout the daytime in our development ecosystems. Even our pythons built in module stones actually help us a lot we need to have a way to standardize things why so because there are a lot of different. There are a lot of different methods and there are a lot of different communication interfaces that we have the back end developers have to interact with front end clients and front end teams have to all the different front end clients live in different regions. So all those things we need to follow a simple single standard. So as dozen of Python mentions it there should be one and preferably only one obvious way to do it. So we came up with multiple different standards ISO 8601 is the governing standard that we all follow and it's related RFC that it's RFC 366 that the internet standards follows. And it's also mentioned about daytime in RFC 282. So there are a lot of different variety of time standards which we follow and among the most common is ISO standard mentioned in RFC and here we follow that there is. A month date and it is then separated by a letter t called time separator, and then we showcase how was minutes seconds milliseconds and then finally the time zone, the time zone. represented by z implies that it is Zulu time or GMT with zero offset or we usually provide offsets like plus 730 plus 530, etc. So we even then we have problems representing and passing time shown there are problems in passing conversion between different time zones there are many inconsistency cost due to changes in daylight saving modes. Some time zones may follow a daylight saving some regions may not follow a daylight saving even though initially their offset would be same. So, even in a single country or a continent there will be multiple different time zones, each having even in the same region. Longitudinally, they will have different time zones. All this things this minor things add up to a lot in and the development process, and they make us frustrated and even political changes or any other people introducing new regions or new time zones have a drastic effect on a developer ecosystems, we need might need to support more standards more protocol and essentially it becomes a maze of that. That all defines even if we saw the time shown issue we have a day issue of daylight savings that some people adopt and even during election period or some kind of. regional politics, they might choose to not follow daylight saving for a year or to all those political actions have a drastic impact on our development ecosystem and our feasibility. And even if we ignore that all our data in Python we the default daytime usually is native daytime if we do not supply any time zone information no time zone is by default saved so the information about time zone might be lost while communicating from front end to back end and then again to the front end so a person living in Asia in India. If it says that 10am and the same information is relied to a person in Europe that changes would be drastic they might get different times and there would be many meetings or many issues that deal with that causes problems. So a simple daytime object created will be a name object and there's another thing that we can support is aware daytime that is time zone aware objects that supported in. Python's built in module and we can easily use that in pendulum or parties said or other information that actually helps and make aware of the time zone rules daylight saving or any other trans transitions and transition that's handled by the library itself. And this is a quick sneak peek to pendulum how they managed to create a time zone aware daytime, even if we supply pure and from a string we pass a time, it actually converts it into UTC by default if no time zone is specified. So to create a name time zone in pendulum we need to explicitly specify its as name. So, we introduce pendulum, it's a popular Python library, it's a direct drop in replacement to daytime, but it is better than daytime as it offers much more handy tools. And it is no more naïve daytime by default, and it offers clear simple handy interfaces and provides flexible and easy ways to use APS they provide a lot of simple helper modules and helper methods like add subprac to string to ISO string. So that started starting up of the project is very simple we just need to install it from PIP or and then we can use it. So, one of the main feature or the primary features are daytime class or which is the direct drop in replacement for standard daytime class, which with which we can easily manipulate our day times. Just like the similar to the built in module, all the methods are there and also we can use simply easily change time zone by using underscore in helper, we can change it into words using to ISO string to WC three string and even shift add as I mentioned we can easily add day times using help add days equal to two, we can reduce subtract using a subtract days equal to two or even add days equal to minus two, we can easily shift across days times and everything, and handling time zones and daytime transition is much more easier thanks to pendulum time zone class, which when we define the time zone as Europe Paris, it actually detects which zone it is transition is enabled by using daytime built in fold which came in Python 3.6 has been back ported to previous versions also in pendulum so anyone can use easily transition between day times and switching off time zones is way easier, we can simply change from one time zone to another using the helper as I mentioned in time zone or it's alias method in TZ. So our development effort will become easier. And the next module is the duration module, which is just a drop in replacement for time delta class, it supports all the similar features are like similar features and it also has a much more better properties. How much weeks is there how much hours is there, what is the duration in hours or in words, we can even set locale which language we want. We can specify in any string conversion we can specify locale equal to ENDE or any other locales so that the wordings will convert into the specified locales. So handing over to Jodit to talk about the period which is a much better version of the duration. Okay, so I've been in just said that pendulum is a much better version of daytime. Arguably, you might want to, you know, go against that you have used daytime your entire life in Python, and my clock is ran fine right it just never broke so why use pendulum what does pendulum So I got you there so I am going to list out a few features of pendulum that actually makes time a lot easier to deal with. So when it comes to the period or the interval class as it has been renamed by pendulum itself. So it's inheriting the duration class which also inherits the time delta from Python. So the period classes represents a period so very. What do you say intuitive I guess right the name represents what it is. So the period class represents a period between two dates or two times so if I create a daytime object or period option. So what I have to do is like create a daytime object first and then I subtract or add that daytime object between two daytime objects so it's a period between these two daytime objects that we deal with right here. So it can be an inverse daytime the day that you're subtracted is like behind the date that you're subtracting from so it's like creates a negative representation of daytime per se. So the period class also gives you these methods which makes life a lot life a lot easier. So it gives you years so if you define two periods like 2021 and 2022. If you try the dot years method, then you'll get one right because obviously it's one year between these two dates and you get months weeks days remaining days how many remaining days to get to the particular date object the delta per se. And you also have hours minutes start and so on. So these methods you can experiment with extensively these just make your life a lot easier when it comes to server based daytime hosting and time time and managing time in general. So the range function this is also one of the features that you might just adore you might just want to hug pendulum by, you know, like tight tight and squeeze pendulum, and when you see this function because it just makes your time flow like anything. So the range function returns an interval, which you can iterate over so it just makes it rating over dates and days and months and years just easier. So it also offers you two methods called subtract and add. So you can iterate if it's an inverse daytime you can actually iterate forward and if it's just a normal data we can also iterate forward or backwards right so this day plus one day or this day minus one day and so you can do those things with these two methods. So this is the exact code that I got from the pendulum source code so you just don't focus on the amount right now if you can see the while loop right here it cast the start date into a pendulum daytime object first and then what it does is uses the method which previously defined is either add or subtract, and then you, it just uses a dictionary unpacking operator to apply that particular method to the start method and the start date. So what you can do is actually add dates if you if you specify the method to be add, then what it does is adds one day along your whatever the daytime object that you specified so if you if you specified February 2nd you can just add one one one one and February 3rd, 4th, 5th, and you can also go backwards if you subtract 4th from 3rd, 2nd, 1st, and so on and so forth. So that just makes iterating over dates much easier since also it is a lazy field so it's a iterator so you don't you don't have to. I mean, I'd hear with the overhead that some other solutions might provide. So the day of the week, you might have seen some mathematicians and even some comedians like. If you ask them the day of the week they'll just spit it out immediately. They are probably using the zealous congruence, which is an algorithm or which is an equation that you can use to simply just, you know, find the day of the week, immediately, even if you ask them what is what is the day of the date of 1864 February 3rd what is the date you can just plug that into this particular equation and you can just output what that day is like on spot right so if you look at this equation I explain this equation in more detail like. So let's go to identify leap years and so on, but let's just skip over to the next slide. Aha so leap years right so what is what are leap years so leap years occur every four years so every year. There are 365 days and six hours that just add up right so thanks to Gregorian calendars you just have to deal with that that's just your life from now on so if you have a grudge with Pope you can fix that now. And you have implicit leap your handling that is a much better way of handling the leap years so. Okay, so when you can see right here, this is the Gregorian rule right every year that is divisible by four is a leap year. So, but if the if the year is also divisible by 100 and not divisible by 400 and it's not a leap year right, so it needs to be divisible by four and divisible by 100 but at the same time do by 400. So, then only can you like predict a leap year so that's a simple equation right. So when it comes to this equation you can see right here how pendulum handles leap years. So this example, you can see, I'm creating an object of a pendulum data and object that represents the date 2024 February 29, which only occurs when a leap year occurs right. So the 29th of February is an accumulation of six hours that you built up over four years into one date that have is that has been squeezed into the 29th of February, again, the Gregorian calendar, but it is the best calendar that we have yet, and it just works right. So, how does pendulum identify leap years as expected, it just uses the Gregorian calendar rule, it's simple and easy no need to change it, it just works. So, this function, when you look at it, it's pretty quite simple. If the year is divisible by four, and your month for equal to zero double equals zero, then, and your month 100 is not zero, or your month 400 is zero, then you have a leap year in your hand. So it returns true. So if you plug in and non leap year into this particular function, then you get false right. So, it's a simple function that has been read directly from the source code and the next. So, yeah, let me give you a great example of this. So, you might identify this state immediately if you live in United States, but the United States but if not this is Arizona. So, United States uses daylight savings time. So daylight savings time is a much more complex process that just adds to the complexity, then it is completely and welcome. So, this needs to be dealt with. So, since we live closer to the equator in India, we just don't use daylight savings time saving us a lot of trouble with daytime right, but we still have to collaborate with other nations other states and all that, which might be in the form of zoom calls meetings, even anything else. So, when it comes to those situations you have to account for daylight savings time, which is a mess. So, in this example, you can see Arizona, right. Arizona, like, unlike you, United States does not use daylight savings time, but even inside Arizona, there's Navajo nation, which does use daylight savings time, like the rest of the United States, but inside Navajo nation, again, you have Hopi, which again does not use daylight savings time inside Hopi, there's Navajo nations, a sub part of Navajo, Navajo nations, which again, and uses daylight savings time. And inside Navajo nation says again, Hopi nation, I mean Hopi region that again does not use Navajo, I mean daylight savings time, like the rest of Arizona. So, if I draw, if I draw a line directly from here traveling through Arizona from the nearby state through Arizona, and if I go to Navajo nation and then I pass through Navajo again, and I go through Hopi and I go through Hopi again and I go through Navajo again and finally I end up in Arizona. This is a mess, you'll be going on your watch like, okay, Arizona, changing the time, Hopi again, changing the time, Navajo nations, changing the time, you might have to do that over seven times, can you believe it? So, daylight savings time is that kind of a mess that is so hard to deal with, like, because so many regions and places existing on this planet Earth that you just can't account for everything. And new daylight savings time rules might be implemented throughout the years, whenever, like randomly. They do not care about programmers, believe me. So, the next side is where we deal with daylight savings time, a cool prototype for you guys to see by the way. So, and let me, I have created two daytime objects here, one for Toronto and one for Vancouver, and this method that just lets us check if this particular daytime object in that particular time zone is a daylight savings time, saving time, time, or like period, or if it's not. So this is a handy method that Pendulum just offers for you guys to see in use. So, and then we have more methods on daylight savings time, which will be explained by Abbott. Thank you, Jyothur. There are a lot of things that you can do in Pendulum. Pendulum by automatically normalizes daytime savings time for you, such that if you are in Paris zone and 230 in the Paris for March 31st of 2013 does not exist. So, the pendulum will return the actual time, which is 330 plus two hours offset. And, but the same time 230 on October 27th of 2013, there exists twice. So, pendulum will assume that transition has occurred and it will show 230 plus one offset. And there's a difference in offset and the time is different. So, this is how pendulum by default handles offset. And we can even customize our offset behavior by assigning the daylight saving rule as per transition or pros transition. And if there is any transition issues or errors, we can handle all the ambiguities of the transition through pendulum. And then, once we have all the nitty gritty sorted out, we use multiple different types of helpers and methods to build our application, we would need to test the application. For that pendulum supports a simple method using the context with context manager pendulum dot test so that we can easily assign a fixed time to that context so that that context will become the current time. And on exiting the context of manager that time defaults to the system time. This is how we can easily test any time for our use cases. And in the upcoming version that is version 3.0 they they will be starting using time machine library, which is another another package and pendulum implements a time travel a traveler method so that we can change the time we can freeze the time we can move forward to the past into the future and all those things will be done much more simpler and we can easily implement all our testing using pendulum. And to see a benchmark of the pendulum, it's actually a detailed benchmark is on the documentation itself, it's taken from there. So the creation of objects, the initial daytime object creation of 10,000 objects, there is a vast different between from arrow, and pendulum is faster and it has a comparable speed in computing the current time and passing is extremely efficient when we are using pendulum. And finally, to say about the differences that our applications once we test and host, we need to follow certain best practices like saving time in UTC, and also along with the time zone information. And by being explicit about the time zones with our daytime objects, we can easily avoid the unexpected behavior in the server differences and our daytime predictions will be accurate. And if we do not account for the time differences that will be in small differences that instead of sending at 8am in the morning scheduled message it will be delivered at seven or nine depending on their current changes in their daytime saving rule. And that's it guys. Thank you for listening. So, we really wanted to be there for the presentation, but we just couldn't get our hands on the visa. So sorry for that. And you guys, if you want to connect, you might want to connect to us on on LinkedIn or get up the same username of each other and I didn't see. So, if you have any questions, please do ask. All right, thank you again. We have time for one question. Is there somebody room right now? I also didn't see anything on the on the discord though. Then I would say like, again, thank you. If you come up with any questions, please DM them directly because they are not here. Also, please take your litter with you and maybe a final round of applause again for them. Thank you. Thank you.