00:01
In this question, the question asks for implementation of function called mydatetime.
00:07
So we have to create this function mydatetime.
00:15
Then what we have to do is, this function should take an integer representing the number of seconds since january 1st, 1970 and converts it to a date string in format mmddyy.
00:36
Why? the function should be able to handle leap years.
00:48
Then it should perform all necessary computation without relying on external libraries.
00:54
It provides example of expected inputs and outputs, demonstrating the desired behavior of the function without any external libraries.
01:16
Let's create this function and see the code for it which satisfies all these conditions.
01:24
So we are in google colab and let's make our datetime function.
01:35
So what we'll do is, first we will define the function like this and we will pass num underscore second as a parameter in it.
01:46
Then we will make a variable seconds in a day.
01:53
So 24 x 60 x 60.
01:58
So when we multiply 24, 60 and 60, we will get the total number of seconds in a day.
02:04
Then we have to find one more parameter that is number of days.
02:12
So we'll create a variable numdays and let it be number of seconds divided by seconds in a day.
02:23
Then startdate january 1st, 1970.
02:34
For that we will declare another three variables like this.
02:48
So then we will run a while loop by writing while true.
02:56
So what it will do is it will start the while loop from the first instance.
03:04
Now we will create a variable called days in a year.
03:09
So we have mentioned 365.
03:14
Then we'll check if year modulus 4 is equal to equal to 0 like this and year modulus of 100 is not equal to 0 or year modulus of 400 is equal to equal to 0.
03:37
Then we have to overwrite this days in year as 366 means what we are doing is we are handling the condition of a leap year here.
03:50
So if this condition checks that this is a leap year, then we will update our days in year variable with 366.
04:00
Now if number of days are less than days in year like this, then what we will do is we will break this for loop.
04:28
Now if this is not true, if number of days are not less than in a year, it will not come out of for loop here and it will run the following two other lines followed by this statement.
04:50
So what it will do is it will perform number of days, days in year.
04:57
It is counting the days and decreasing the days from this year.
05:03
So number of days equal to number of days minus days in year...