00:01
Okay, so this question says, it says, write a function that takes three arguments, year, month, day, and returns to corresponding day.
00:20
So we're going to use date time package for this, so import date time.
00:26
And what we want here is it to get three arguments, so we're going to have f -a of week, i guess, and we'll say it takes year, month, day.
00:38
To be commas, and what we're going to do is we're going to do date time.
00:46
Well, first of all, we want to convert this to a date time, right? so if we have three numbers, date, time, there should be a way to convert that to a date time, right? so we're going to use the strp time function to do that.
01:06
So we're going to do date time.
01:11
Going to give it a string made out of these things.
01:15
So we're going to say stir year, stir y, plus slash plus stir m, plus slash, plus stir, and let's run that and see if it works.
01:32
Nope.
01:32
So module daytime has no attribute strip time, of course.
01:37
That's my mistake.
01:39
That's a java function.
01:40
So we're going to find the corresponding python.
01:43
And the fix for this is, is to actually just do date time dot datetime dot strp time until let's do 1900 let's do 03 3 i guess and let's do 10 okay so that didn't work and that's because um we also have to give it the format we want so we have to do uh like this we say 1 % y slash percent m slash percent the other and let's see why it says this did not match the format um and let's see why it didn't match the format so the string looks like this and perhaps it needs to receive uh the same number of of uh variables there that it gets so for example, if this was one, so obviously something's wrong here.
03:16
We need to figure out what.
03:18
And so we're actually going to try doing this in a totally different way because this strip time function is very finicky.
03:25
And this one thing that's good to learn is when you're coding, you want to try different things and find something that works the best.
03:31
So we're going to completely get rid of this scrp time.
03:35
Instead we're just going to build this date time manually.
03:37
So we're going to do year, month, day.
03:39
We're going to put it right inside here okay and instead of trying to construct the date time from a string what we're doing we're just going to construct it straight from these numbers okay and then what we're going to do is we're going to find the day of the week by saying uh well we'll we'll call this we'll say my d t my date time and we'll say my d t or we'll say day of week equals my dt dot a got weekday and that will return uh so that'll return you know week that'll return um it's 2020 08 13 um 8 13 so that's 5 5 was 5 mean 5 is index 5 so we go monday or we go sunday monday tuesday wednesday thursday friday and today is actually not a friday, but i also typed in wrong numbers here.
04:54
So we have sunday, monday, tuesday.
04:59
Sunday is zero.
05:02
Monday, tuesday, wednesday, thursday, friday, friday.
05:04
Saturday, there it is.
05:11
But that, again, is not consistent with what i've said.
05:17
So it makes me wonder if date time is interpreting this is the day.
05:24
And this is the month.
05:25
So let's try flipping that.
05:27
No, i guess not.
05:32
So let's figure out then why we're getting a friday for today.
05:39
So maybe it just doesn't count from sunday.
05:46
Ah, okay.
05:47
So i'm looking at the documentation now.
05:50
It says monday is zero and it counts up to sunday as six.
05:53
So five then means saturday.
05:57
Okay, so here's what we're going to do.
05:58
We're going to say, so since our code is supposed to return the corresponding day of the year...