WEBVTT 1 00:00:00.150 --> 00:00:01.830 Hi there and welcome back. 2 00:00:01.830 --> 00:00:04.940 In this video we're talking about timezones. 3 00:00:04.940 --> 00:00:07.400 If you've never heard of a timezone before 4 00:00:08.420 --> 00:00:09.920 that's a bit strange, 5 00:00:09.920 --> 00:00:14.390 but a timezone is essentially a slice of the world 6 00:00:14.390 --> 00:00:17.690 where it is a time at any point in time, 7 00:00:17.690 --> 00:00:21.917 and the time differs between other timezones. 8 00:00:21.917 --> 00:00:23.520 That's substantially what they are 9 00:00:23.520 --> 00:00:25.430 so there's a lot of timezones, 10 00:00:25.430 --> 00:00:27.040 there's a lot of countries in the world 11 00:00:27.040 --> 00:00:29.346 and of course the time here in the UK 12 00:00:29.346 --> 00:00:34.240 is not the same time as in for example in Madrid, 13 00:00:34.240 --> 00:00:37.210 is not the same time as in Shanghai. 14 00:00:37.210 --> 00:00:39.530 So the times are different of course because 15 00:00:39.530 --> 00:00:43.270 we generally want there to be sunlight during the day 16 00:00:43.270 --> 00:00:47.110 and we generally want it to be dark during the night, 17 00:00:47.110 --> 00:00:50.610 so not every country is light during the same time 18 00:00:50.610 --> 00:00:54.090 some countries are dark when here it is light and so forth. 19 00:00:54.090 --> 00:00:56.840 So the time varies depending in where you are in the world 20 00:00:56.840 --> 00:00:57.820 at any given point. 21 00:00:58.790 --> 00:01:01.650 So some countries have actually many timezones, 22 00:01:01.650 --> 00:01:04.560 for example the United States has a few timezones 23 00:01:04.560 --> 00:01:07.380 as you go from left to right is a very large country. 24 00:01:07.380 --> 00:01:10.350 So sometimes the time changes when you are 25 00:01:10.350 --> 00:01:12.210 within the same country, that's fine. 26 00:01:14.000 --> 00:01:17.110 However some very large countries only have one timezone. 27 00:01:17.110 --> 00:01:18.410 For example India, 28 00:01:18.410 --> 00:01:19.540 is an example. 29 00:01:20.390 --> 00:01:22.050 And which can be a bit strange 30 00:01:22.050 --> 00:01:23.160 because of course 31 00:01:23.160 --> 00:01:25.440 when you are at the left most part of the country 32 00:01:25.440 --> 00:01:27.770 it is a given time, and if you where to teleport 33 00:01:27.770 --> 00:01:30.560 to the rightmost part of the country it may be dark, 34 00:01:30.560 --> 00:01:32.010 but it's still the same time. 35 00:01:33.130 --> 00:01:37.430 Normally the difference between two adjacent timezones 36 00:01:37.430 --> 00:01:39.340 is of one hour. 37 00:01:39.340 --> 00:01:40.920 That's just the most common thing, 38 00:01:40.920 --> 00:01:44.320 so for example I am in one timezone here in the UK, 39 00:01:44.320 --> 00:01:49.030 the adjacent timezone is sort of European West Time Zone 40 00:01:49.030 --> 00:01:50.950 like Madrid and Germany. 41 00:01:50.950 --> 00:01:54.240 And the difference between here and there is one hour. 42 00:01:55.180 --> 00:01:56.880 However something that a lot of people don't know 43 00:01:56.880 --> 00:01:58.220 is that sometimes the difference 44 00:01:58.220 --> 00:02:00.810 between two adjacent timezones can be less than that, 45 00:02:00.810 --> 00:02:02.820 it can be 15 minutes, it can be 30 minutes, 46 00:02:02.820 --> 00:02:04.740 it can be 45 minutes. 47 00:02:04.740 --> 00:02:08.720 So timezones are not all that stable, 48 00:02:08.720 --> 00:02:12.420 and also some countries pick out a time 49 00:02:12.420 --> 00:02:14.310 and a timezone because it suits them 50 00:02:14.310 --> 00:02:15.530 sometimes politically, 51 00:02:15.530 --> 00:02:17.920 sometimes to be in the same time as 52 00:02:17.920 --> 00:02:20.120 neighbour countries that they have good relations with, 53 00:02:20.120 --> 00:02:20.953 so forth. 54 00:02:20.953 --> 00:02:23.330 So the timezone is not really 55 00:02:23.330 --> 00:02:26.647 well it is sort of depending on your position in the world 56 00:02:26.647 --> 00:02:30.080 but it's not really depending on your position in the world 57 00:02:30.080 --> 00:02:32.060 so it is dependent on the country 58 00:02:32.060 --> 00:02:33.480 that you're in essentially. 59 00:02:34.570 --> 00:02:37.510 So what time is it right now? 60 00:02:38.960 --> 00:02:40.610 My computer says 61 00:02:40.610 --> 00:02:44.700 it is 2018 February 11th, at 10:34 a.m. 62 00:02:46.150 --> 00:02:47.570 But of course to you, 63 00:02:47.570 --> 00:02:50.160 if you were watching this live right now 64 00:02:50.160 --> 00:02:52.750 to you that might be a lie. 65 00:02:52.750 --> 00:02:55.430 For example if you were in America at this time 66 00:02:55.430 --> 00:02:57.070 the time could be 2:00 a.m. 67 00:02:58.390 --> 00:03:02.500 So this is a lie, unless I tell you where I am. 68 00:03:02.500 --> 00:03:04.160 If I tell you where I am 69 00:03:04.160 --> 00:03:09.160 then I'm not saying that the current time is 10:34 for you 70 00:03:09.290 --> 00:03:11.810 I'm just saying the current time is 10:34 for me 71 00:03:11.810 --> 00:03:13.250 in my current location. 72 00:03:14.830 --> 00:03:17.430 So the current time right now 73 00:03:17.430 --> 00:03:20.270 is 10:34 in UK/London, 74 00:03:20.270 --> 00:03:22.370 and the timezone for this is called (GMT). 75 00:03:24.000 --> 00:03:27.670 But is actually 11:34 in Spain/Madrid 76 00:03:27.670 --> 00:03:29.770 where the current time is Central Eastern, 77 00:03:31.350 --> 00:03:33.220 or Central European, The Central European Time, 78 00:03:33.220 --> 00:03:35.040 I'm pretty sure The Central European, never mind. 79 00:03:35.040 --> 00:03:36.140 Central European Time. 80 00:03:37.290 --> 00:03:40.820 However is 2:34 a.m. in San Francisco which has a (PST), 81 00:03:41.940 --> 00:03:45.190 and it's half six in China/Shanghai 82 00:03:45.190 --> 00:03:47.100 where they have Chinese Standard Time. 83 00:03:48.090 --> 00:03:51.170 So you can see that is the time right now. 84 00:03:51.170 --> 00:03:53.760 Any of those is correct, 85 00:03:53.760 --> 00:03:55.730 because I'm telling you the time 86 00:03:55.730 --> 00:03:57.830 and also the timezone. 87 00:03:59.190 --> 00:04:01.700 That way for you 88 00:04:01.700 --> 00:04:04.250 when you know the timezone you can convert 89 00:04:04.250 --> 00:04:07.610 my current time into your current time without a problem. 90 00:04:09.010 --> 00:04:10.720 So the question becomes 91 00:04:10.720 --> 00:04:14.240 can you never speak of dates without mentioning a timezone? 92 00:04:17.350 --> 00:04:18.350 No. 93 00:04:18.350 --> 00:04:19.183 You cannot. 94 00:04:20.060 --> 00:04:21.170 However, 95 00:04:21.170 --> 00:04:24.640 there is a central reference point that everyone can use. 96 00:04:24.640 --> 00:04:28.220 Normally when we don't say the timezone 97 00:04:28.220 --> 00:04:31.210 we must imply it, we must say 98 00:04:31.210 --> 00:04:32.043 we don't mention the timezone 99 00:04:32.043 --> 00:04:34.520 because this is the sort of the default timezone. 100 00:04:35.620 --> 00:04:38.390 And so that is UTC, 101 00:04:39.490 --> 00:04:42.930 and which stands for Coordinated Universal Time. 102 00:04:42.930 --> 00:04:45.094 And yeah, I don't understand the acronym. 103 00:04:45.094 --> 00:04:47.450 But actually that's also a sort of a lie 104 00:04:47.450 --> 00:04:48.283 I can understand the acronym 105 00:04:48.283 --> 00:04:49.116 you can Google it if you're interested 106 00:04:49.116 --> 00:04:51.210 in what the acronym means, it doesn't mean anything. 107 00:04:52.260 --> 00:04:54.460 But, nonetheless there is a central reference point 108 00:04:54.460 --> 00:04:57.250 so normally when we don't specify a time 109 00:04:57.250 --> 00:04:59.140 that's because we mean UTC, 110 00:04:59.140 --> 00:05:00.610 which is the Central Time. 111 00:05:01.940 --> 00:05:03.790 And the Central Time here UTC 112 00:05:03.790 --> 00:05:06.380 is based not on political reasons 113 00:05:06.380 --> 00:05:08.250 so it doesn't depend on the country, 114 00:05:08.250 --> 00:05:11.000 it was decided and it sort of depends on a few factors. 115 00:05:12.360 --> 00:05:15.270 So the central referent point is important 116 00:05:15.270 --> 00:05:17.540 because when we talk about timezones 117 00:05:17.540 --> 00:05:19.720 like for examples CET, 118 00:05:21.250 --> 00:05:25.870 we say that it is relative to UTC by one hour. 119 00:05:25.870 --> 00:05:29.250 GMT is relative to UTC by zero hours 120 00:05:29.250 --> 00:05:30.083 and so forth. 121 00:05:30.083 --> 00:05:33.060 So every timezone is related to UTC 122 00:05:33.060 --> 00:05:35.680 in how far away they are from it. 123 00:05:35.680 --> 00:05:39.210 UTC passes thought Greenwich in the UK. 124 00:05:42.400 --> 00:05:45.010 So, the date and times in Python 125 00:05:45.010 --> 00:05:48.810 there are two types of date and time entities, 126 00:05:48.810 --> 00:05:50.550 there is the date and times object in Python 127 00:05:50.550 --> 00:05:52.600 that does not know about timezones, 128 00:05:53.540 --> 00:05:57.120 and that is called a "naïve" date and time object. 129 00:05:57.120 --> 00:05:58.730 You can create one like this, 130 00:05:58.730 --> 00:06:02.140 you can say from datetime import datetime 131 00:06:02.140 --> 00:06:04.720 and do something like print datetime.now. 132 00:06:05.660 --> 00:06:07.550 That is going to give you the current time 133 00:06:07.550 --> 00:06:09.810 in your computer, 134 00:06:09.810 --> 00:06:12.650 but it's not gonna tell you what timezone that's in. 135 00:06:14.240 --> 00:06:17.870 So not that useful I would say. 136 00:06:17.870 --> 00:06:19.930 Because for example if you were to save that 137 00:06:19.930 --> 00:06:22.390 into a file or a database 138 00:06:22.390 --> 00:06:24.150 when you come back to it 139 00:06:24.150 --> 00:06:25.440 you won't really know 140 00:06:25.440 --> 00:06:28.860 if that was the current time in your computer, 141 00:06:28.860 --> 00:06:30.630 or the current time in somebody else's computer, 142 00:06:30.630 --> 00:06:34.450 and how that relates to the current time in your computer. 143 00:06:34.450 --> 00:06:37.500 You don't know exactly what time it was. 144 00:06:38.520 --> 00:06:41.600 One date and time object that does know about timezones 145 00:06:41.600 --> 00:06:43.270 is called an aware object, 146 00:06:43.270 --> 00:06:46.850 because it is sort of more "aware" of the world around it. 147 00:06:46.850 --> 00:06:47.940 And in order to create one of them 148 00:06:47.940 --> 00:06:51.460 you can do from datetime import datetime and timezone, 149 00:06:51.460 --> 00:06:53.870 and you can print datetime.now 150 00:06:53.870 --> 00:06:56.560 but giving it the timezone.utc 151 00:06:56.560 --> 00:06:58.230 and that's gonna give you the current time 152 00:06:58.230 --> 00:07:02.230 in the UTC timezone which as I said is the Central timezone. 153 00:07:03.129 --> 00:07:04.910 As an aside 154 00:07:04.910 --> 00:07:07.730 UTC is not actually a timezone, 155 00:07:07.730 --> 00:07:09.350 so it's just a central point 156 00:07:09.350 --> 00:07:12.260 and in the Python datetime library, 157 00:07:12.260 --> 00:07:13.690 what we're importing here 158 00:07:13.690 --> 00:07:14.970 it is treated as a timezone 159 00:07:14.970 --> 00:07:16.460 but it's not actually a timezone, 160 00:07:16.460 --> 00:07:20.400 there is no country that uses UTC as their time. 161 00:07:20.400 --> 00:07:22.170 And but it is the central reference point 162 00:07:22.170 --> 00:07:24.810 and is really an important thing. 163 00:07:24.810 --> 00:07:26.480 So in the next video 164 00:07:26.480 --> 00:07:28.290 were going to talk about dates and times in Python 165 00:07:28.290 --> 00:07:31.720 and how I advice that you work with them. 166 00:07:31.720 --> 00:07:34.870 Now dates and times are a bit of a thorny issue 167 00:07:34.870 --> 00:07:37.850 and a bit of a difficult one at that. 168 00:07:37.850 --> 00:07:40.210 And there's a lot of different libraries that you can use 169 00:07:40.210 --> 00:07:42.850 to manage dates and times in Python. 170 00:07:42.850 --> 00:07:44.510 The built in date library 171 00:07:45.460 --> 00:07:47.200 is pretty good, 172 00:07:47.200 --> 00:07:49.350 but it doesn't support some things 173 00:07:49.350 --> 00:07:50.930 and it supports other things. 174 00:07:50.930 --> 00:07:52.330 So there's also a bit of a trade off 175 00:07:52.330 --> 00:07:54.300 to do between datetime libraries. 176 00:07:54.300 --> 00:07:57.590 If you find that what you want to do with date and times 177 00:07:57.590 --> 00:08:01.610 is difficult with the included datetime library, 178 00:08:01.610 --> 00:08:03.820 feel free to look into other libraries 179 00:08:03.820 --> 00:08:05.960 which also can help you. 180 00:08:05.960 --> 00:08:08.445 An example of such a library is one called Arrow, 181 00:08:08.445 --> 00:08:12.170 that can be quite an interesting library to use as well. 182 00:08:12.170 --> 00:08:13.880 Nonetheless in this course we're gonna talk about 183 00:08:13.880 --> 00:08:15.720 what comes with Python, 184 00:08:15.720 --> 00:08:17.030 just because it is pretty powerful 185 00:08:17.030 --> 00:08:19.000 and it does a lot of the things we need. 186 00:08:19.000 --> 00:08:22.000 And which includes reading dates and times, 187 00:08:22.000 --> 00:08:24.260 understanding when a user types a date and a time 188 00:08:24.260 --> 00:08:25.530 what it means, 189 00:08:25.530 --> 00:08:26.700 exporting dates and times 190 00:08:26.700 --> 00:08:28.730 and printing them out to users nicely, 191 00:08:28.730 --> 00:08:29.970 calculating this in times 192 00:08:29.970 --> 00:08:32.300 and for example what time will it be tomorrow 193 00:08:33.780 --> 00:08:34.613 at this time, 194 00:08:34.613 --> 00:08:36.060 or what date will it be tomorrow at this time, 195 00:08:36.060 --> 00:08:37.389 and so forth. 196 00:08:37.389 --> 00:08:39.630 Is quite a lot of stuff we can do with a datetime library, 197 00:08:39.630 --> 00:08:40.600 so let's go can twit 198 00:08:40.600 --> 00:08:41.890 in the very next video. 199 00:08:41.890 --> 00:08:42.840 I'll see you there.