WEBVTT 00:04.600 --> 00:09.730 In this coning lecture, I'm going to solve the parts of a day challenge, let's get started. 00:12.650 --> 00:14.550 All right, now let's get back to the court. 00:17.750 --> 00:22.820 Now I'm going to short declare a variable age like this, this will store the current our. 00:24.370 --> 00:27.490 Now, I'm going to call the now function from the time package. 00:28.640 --> 00:31.630 Then in turn from it, I'm going to call our method. 00:32.950 --> 00:38.230 As I showed you before time, that now here returns a time value for the current site. 00:39.250 --> 00:40.600 And it has aberrated. 00:42.010 --> 00:44.690 As you can see, it returns to Iowa as an int. 00:45.250 --> 00:48.670 So now this age variable here is also an incredible. 00:51.990 --> 00:54.780 OK, let's print this variable to the console like this. 00:59.860 --> 01:00.780 Now, let's run it. 01:03.430 --> 01:05.770 As you can see it, Prince, the current our. 01:06.970 --> 01:11.410 All right, let's get back and print the part of today, using this our way will. 01:12.460 --> 01:16.120 First, I'll check whether the current hour is around evening like this. 01:18.080 --> 01:20.480 If so, then I'll print good evening. 01:22.970 --> 01:26.210 Now, let's check for the afternoon part of the day like this. 01:28.100 --> 01:32.330 So it's not the evening time, nor we'll check this second case condition. 01:33.640 --> 01:38.530 So if the hour is greater than or equal to 12, then it should be afternoon. 01:39.500 --> 01:43.870 As you can see, the order of the case clauses are very important to this program. 01:44.980 --> 01:48.340 On each case, I'm trying to narrow the range of Iris. 01:49.780 --> 01:52.930 Now, let's check for the morning part of the day like this. 01:56.850 --> 02:03.300 And lastly, if the hour is less than six, then it should be night dango as a last resort will execute 02:03.300 --> 02:04.440 this default class. 02:05.800 --> 02:06.970 Now, the program is really. 02:08.160 --> 02:14.460 Now, let's move this short declaration into the swift statement like this, I'm going to cut it from 02:14.460 --> 02:16.470 here and move it to here. 02:18.390 --> 02:23.430 Here, I've just moved the short declaration that I put the surprise there are next to it with an empty 02:23.430 --> 02:26.910 condition, remember, an empty condition means true. 02:27.890 --> 02:31.520 First, let me set my clock to a morning hour from here. 02:32.470 --> 02:33.080 Apply. 02:33.720 --> 02:36.180 OK, now let's run the program. 02:38.020 --> 02:38.420 Cool. 02:38.680 --> 02:39.950 Good morning to you, too. 02:40.300 --> 02:43.540 But it's not morning here, I'm just faked it anyway. 02:44.700 --> 02:46.950 Now, I'm going to set my time to afternoon. 02:49.370 --> 02:50.660 OK, that's right now. 02:51.810 --> 02:53.640 Good note says good afternoon. 02:55.140 --> 02:57.590 Now, let's set my time to evening. 03:00.190 --> 03:01.720 Now it says good evening. 03:02.780 --> 03:05.720 And lastly, that set my time tonight, our. 03:08.810 --> 03:09.270 Good. 03:09.290 --> 03:10.490 It works perfectly. 03:11.770 --> 03:17.380 By the way, since I've declared the Arabel travel inside switch statement, it won't be available here. 03:18.430 --> 03:20.830 So, for example, I can't print it like this. 03:22.730 --> 03:25.490 As you can see, Gore says that it doesn't exist here. 03:26.150 --> 03:31.090 You can learn more information about this in their statements, scoping and the shadowing lectures, 03:31.100 --> 03:31.550 by the way. 03:32.490 --> 03:35.550 All right, that's all for now, see in the next picture, bye bye.