1 00:00:00,180 --> 00:00:12,060 Time delta plus a time Delta is a duration expressing the difference between due date or daytime objects 2 00:00:13,300 --> 00:00:23,950 so a time Delta represents the time difference between two events and it is normally used to add or 3 00:00:23,950 --> 00:00:30,910 remove a certain duration of time from a date or a daytime object. 4 00:00:30,910 --> 00:00:37,570 These are the following attributes defined in the time Delta class days. 5 00:00:37,780 --> 00:00:43,370 Second microseconds milliseconds minute. 6 00:00:43,570 --> 00:00:49,940 I was and weeks in order to create a time Delta object. 7 00:00:50,020 --> 00:00:59,200 We simply need to parse a specified duration to the class constructor and by default a single integer 8 00:00:59,230 --> 00:01:06,810 pass to the class constructor the present number of days so time. 9 00:01:06,840 --> 00:01:13,850 Delta of 10 gives us an object that represents 10 days. 10 00:01:13,870 --> 00:01:23,190 Let us now create a time Delta object indeed JUPITER KNOWN book Let does not create a time Delta object. 11 00:01:23,190 --> 00:01:28,580 Delta 1 we will pass these values to the constructor. 12 00:01:28,650 --> 00:01:41,590 Time Delta constructor so we will begin with the attribute weeks and then days minutes was microseconds 13 00:01:42,810 --> 00:01:48,340 so these are the different attributes that we are going to pass to the class constructor execute this 14 00:01:48,340 --> 00:01:53,920 in and then display the object Delta 1. 15 00:01:54,090 --> 00:02:07,680 The first attribute in this instance that is Delta 1 represents the number of days so Delta 1 dog days 16 00:02:07,980 --> 00:02:17,970 is going to give me the first attribute to value the second attribute for this particular instance is 17 00:02:19,510 --> 00:02:20,820 second. 18 00:02:21,150 --> 00:02:29,900 So Delta 1 dot second represents the value of the attribute second for this particular instance. 19 00:02:30,030 --> 00:02:43,620 Delta 1 and then the third attribute is microseconds which is 23 now when creating these object Delta 20 00:02:43,620 --> 00:02:44,230 1. 21 00:02:44,280 --> 00:02:55,640 We have passed the argument weeks days minutes hours and microseconds now when we display the object 22 00:02:55,640 --> 00:02:57,360 Delta 1. 23 00:02:57,440 --> 00:03:05,750 It only shows the attributes for days seconds and then microseconds. 24 00:03:05,750 --> 00:03:14,690 This is because internally the attribute days seconds and microseconds are stored and all other arguments 25 00:03:14,690 --> 00:03:17,240 like weeks milliseconds. 26 00:03:17,240 --> 00:03:25,790 I was at all converted to these units that these days seconds and microseconds. 27 00:03:25,790 --> 00:03:33,950 So in our example when creating the object Delta 1 these are the values we have passed to the class 28 00:03:33,950 --> 00:03:35,060 constructor. 29 00:03:35,060 --> 00:03:42,000 Now when we display the object Delta 1 This is what is shown in the output. 30 00:03:42,020 --> 00:03:51,200 This is because internally only the attribute days seconds and microseconds are stored and all other 31 00:03:51,260 --> 00:04:01,670 attributes say for example weeks is converted two days so one week. 32 00:04:01,680 --> 00:04:12,720 In our example is converted to 7 days and then minutes is converted to seconds with the 60 seconds the 33 00:04:12,720 --> 00:04:16,570 attribute hours is converted to seconds. 34 00:04:16,740 --> 00:04:28,020 So there are 60 into 60 seconds in an hour and so on the attribute millisecond is converted two thousand 35 00:04:28,380 --> 00:04:39,750 microseconds minute is converted to 60 seconds an hour is converted to 3600 seconds and displayed in 36 00:04:39,750 --> 00:04:41,970 the output accordingly. 37 00:04:41,970 --> 00:04:50,340 So if you create a time Delta object but arbitrary combination of time durations represented with days 38 00:04:50,460 --> 00:05:01,020 weeks minutes hours etc. and that combination will be simplified to represent the time Delta object 39 00:05:01,080 --> 00:05:14,160 in days seconds and microseconds all the different parameters defined in the time Delta class add optional. 40 00:05:14,490 --> 00:05:23,120 So if you do not pass any value to a parameter that means a default value of zero is assumed and due 41 00:05:23,120 --> 00:05:32,280 value to these arguments can be integers floating by numbers and can also be a positive or a negative 42 00:05:32,280 --> 00:05:32,760 number. 43 00:05:33,090 --> 00:05:41,630 We will now see these valid range of values for a time Delta object by calling the attribute men. 44 00:05:41,670 --> 00:05:46,830 This is the minimum value of a time Delta object. 45 00:05:46,830 --> 00:05:57,330 Next we will call the attribute Max and these are the maximum representing all values for a time Delta 46 00:05:57,360 --> 00:06:05,820 object for days and then seconds and microseconds coming to this attribute men. 47 00:06:05,970 --> 00:06:14,670 If you want to create a time Delta object using the least possible value it is going to be this value 48 00:06:14,760 --> 00:06:19,010 and this negative value represents days. 49 00:06:19,050 --> 00:06:30,120 Keep in mind that the time Delta object can only have a negative value in these days field and no other 50 00:06:30,210 --> 00:06:35,720 attribute other than the days attribute can be represented as a negative number. 51 00:06:35,850 --> 00:06:44,820 No let us try creating a time Delta object by giving a negative value for the second field but let's 52 00:06:44,820 --> 00:06:51,640 call this object Delta 2 and to the class constructor time Delta. 53 00:06:51,640 --> 00:07:03,130 We are going to parse two arguments days is 1 and then seconds is minus 4000. 54 00:07:03,730 --> 00:07:14,890 Let's execute this line and then display the object Delta 2 the time Delta object is represented like 55 00:07:14,890 --> 00:07:18,670 this in days and in seconds. 56 00:07:18,670 --> 00:07:20,790 So how was this conversion done. 57 00:07:20,800 --> 00:07:30,040 Let's talk about that so we have just discussed that no other attribute other than the D attribute can 58 00:07:30,040 --> 00:07:32,440 be represented as a negative number. 59 00:07:32,980 --> 00:07:42,280 But when creating the object a time Delta object we have passed a negative value to the attribute now 60 00:07:42,580 --> 00:07:54,050 in the background the value of the days attribute is converted into seconds so that add 24 in to 60 61 00:07:54,070 --> 00:07:56,600 into 60 seconds in a day. 62 00:07:57,490 --> 00:08:09,010 Which is eighty six thousand four hundred and now this value is added to the second value in this attribute 63 00:08:10,490 --> 00:08:13,980 so minus four thousand. 64 00:08:14,120 --> 00:08:17,210 This is going to give eighty two thousand four hundred 65 00:08:20,250 --> 00:08:26,270 so the time Delta object Delta 2 will now be represented like this. 66 00:08:26,400 --> 00:08:33,490 Days is zero and then second is this value. 67 00:08:33,600 --> 00:08:39,410 We will now see some of the methods that are defined in the time Delta class. 68 00:08:39,930 --> 00:08:48,390 Let's call the desired function and parse time Delta to this function. 69 00:08:48,810 --> 00:08:51,450 We will first begin with the the method. 70 00:08:51,540 --> 00:08:53,410 Total seconds. 71 00:08:53,400 --> 00:08:56,940 Now let's call the method. 72 00:08:56,940 --> 00:09:02,670 Total seconds on this object. 73 00:09:02,670 --> 00:09:09,560 This method total second gives total number of seconds represented by this object. 74 00:09:10,320 --> 00:09:14,310 Let's call this method again on another object. 75 00:09:14,310 --> 00:09:15,430 Delta 1. 76 00:09:15,480 --> 00:09:18,850 Total number of seconds for this particular instance. 77 00:09:18,900 --> 00:09:20,560 Delta 1. 78 00:09:20,580 --> 00:09:23,670 Next we will call the built in function. 79 00:09:23,700 --> 00:09:35,480 A B is and then pass the object Delta 1 and the ABC s function it returns distorted. 80 00:09:35,510 --> 00:09:47,420 Duration of the particular instance which is represented as a positive number say for example we will 81 00:09:47,840 --> 00:09:58,850 pass another time Delta object which has the days as a negative value minus 1 and then execute this 82 00:09:58,850 --> 00:09:59,870 line. 83 00:09:59,870 --> 00:10:09,170 The built in function a b is has returned an absolute value for the attribute D which is a positive 84 00:10:09,170 --> 00:10:10,220 number. 85 00:10:10,220 --> 00:10:19,280 The time Delta object supports various mathematical operations such as addition subtraction multiplication 86 00:10:19,610 --> 00:10:24,860 division modulo etc. Using basic operators. 87 00:10:24,860 --> 00:10:33,370 So let's discuss about some of these mathematical operations beginning with the method double underscore 88 00:10:33,590 --> 00:10:34,050 month. 89 00:10:35,420 --> 00:10:40,800 So let's call this method on the object Delta 1. 90 00:10:41,000 --> 00:10:51,080 The method w underscored model allows for the multiplication of time Delta object by numbers execute 91 00:10:51,110 --> 00:10:52,150 this line. 92 00:10:52,250 --> 00:11:00,170 Each of the attributes defined in this time Delta object Delta 1 has been multiplied with this integer 93 00:11:00,350 --> 00:11:09,340 to next we will call the float division method the flawed division method allows dividing one time Delta 94 00:11:09,430 --> 00:11:16,180 object by another time Delta or by an integer flawed or a decimal value. 95 00:11:16,660 --> 00:11:24,940 So in this we are going to divide a time Delta object Delta 1 by the integer to let execute this 96 00:11:27,590 --> 00:11:32,540 and the flawed division compute the questioned and they demanded. 97 00:11:32,720 --> 00:11:38,640 The remainder is thrown away and this is decommissioned a time Delta object. 98 00:11:39,900 --> 00:11:48,290 Next we will talk about the string method these string method returns a string representation of our 99 00:11:48,290 --> 00:11:49,970 time Delta object. 100 00:11:50,180 --> 00:11:55,100 So let's parse the object Delta 1 to the method string 101 00:11:58,190 --> 00:12:10,660 and this returns a string in the form of days I was minutes and seconds if I did time object is subtracted 102 00:12:10,660 --> 00:12:18,080 from another daytime object the value that is added don't is that the time. 103 00:12:18,080 --> 00:12:20,450 Time delta so let's see this. 104 00:12:20,470 --> 00:12:35,900 Let's subtract D2 2 from D2 1 which are 2 daytime objects let's execute this line and the result is 105 00:12:36,470 --> 00:12:38,490 a time Delta object. 106 00:12:39,610 --> 00:12:45,030 Which has these two attributes one is the days and the other. 107 00:12:45,070 --> 00:12:45,650 Second 108 00:12:48,790 --> 00:12:56,410 so if you subtract a daytime object from another daytime object the value that is red done is of the 109 00:12:56,410 --> 00:12:58,000 type time Delta. 110 00:12:58,000 --> 00:13:09,190 Now if you add a daytime object to a time Delta which is say a specified duration this is going to result 111 00:13:09,250 --> 00:13:12,640 in a daytime object. 112 00:13:12,640 --> 00:13:24,740 And if you add to time Delta objects say Delta 1 and Delta 2 this is going to determine what time Delta 113 00:13:24,860 --> 00:13:25,640 object. 114 00:13:25,640 --> 00:13:33,950 The difference between these two daytime objects as Delta 3 lit displayed this object. 115 00:13:34,220 --> 00:13:35,060 Delta 3. 116 00:13:35,060 --> 00:13:38,380 So this is a time Delta object. 117 00:13:38,380 --> 00:13:48,370 Now as discussed let's add the daytime object d d to do a time Delta object. 118 00:13:48,440 --> 00:13:49,550 Delta 3. 119 00:13:49,550 --> 00:13:52,280 Let's execute this line. 120 00:13:52,340 --> 00:14:03,080 And this addition operation has returned a daytime object which has the same values as the daytime object 121 00:14:03,080 --> 00:14:16,300 D.T. 1 so subtracting date produces a time Delta object and a time Delta object can be added or subtracted 122 00:14:16,390 --> 00:14:21,040 from a date to produce another date. 123 00:14:21,040 --> 00:14:26,910 And this brings us to the end of this tutorial on time Delta. 124 00:14:26,920 --> 00:14:27,550 Class.