Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
1
00:00:01,420 --> 00:00:04,993
Let's now perform some operations with dates.
2
2
00:00:06,620 --> 00:00:09,880
So one cool thing that we can do with dates
3
3
00:00:09,880 --> 00:00:12,410
is to do calculations with them.
4
4
00:00:12,410 --> 00:00:14,910
For example, we can subtract one date
5
5
00:00:14,910 --> 00:00:16,470
from another date,
6
6
00:00:16,470 --> 00:00:19,550
in order to calculate how many days have passed
7
7
00:00:19,550 --> 00:00:21,890
between the two dates.
8
8
00:00:21,890 --> 00:00:23,060
And this works,
9
9
00:00:23,060 --> 00:00:26,110
because whenever we attempt to convert a date
10
10
00:00:26,110 --> 00:00:29,440
to a number, then the result is going to be the
11
11
00:00:29,440 --> 00:00:31,830
timestamp in milliseconds.
12
12
00:00:31,830 --> 00:00:33,320
And with these milliseconds,
13
13
00:00:33,320 --> 00:00:36,130
we can then perform calculations.
14
14
00:00:36,130 --> 00:00:40,140
So again, the timestamps are going to be really helpful here
15
15
00:00:40,140 --> 00:00:42,000
in this situation.
16
16
00:00:42,000 --> 00:00:44,083
So let's get this date here.
17
17
00:00:46,460 --> 00:00:50,193
Okay, and let me just demonstrate what I just said.
18
18
00:00:51,310 --> 00:00:55,433
So I will convert to a number, this feature.
19
19
00:00:57,430 --> 00:00:59,860
So you see, it worked.
20
20
00:00:59,860 --> 00:01:01,340
And the same thing is going to happen
21
21
00:01:01,340 --> 00:01:03,933
when I use the plus operator on it.
22
22
00:01:05,970 --> 00:01:07,300
So you see.
23
23
00:01:07,300 --> 00:01:08,210
And so in fact,
24
24
00:01:08,210 --> 00:01:11,590
that does mean we can now do operations with it.
25
25
00:01:11,590 --> 00:01:14,140
So if we subtract one date from another,
26
26
00:01:14,140 --> 00:01:17,260
the result is going to be a number like this.
27
27
00:01:17,260 --> 00:01:19,660
So a timestamp in milliseconds.
28
28
00:01:19,660 --> 00:01:21,400
And then we can simply convert
29
29
00:01:21,400 --> 00:01:24,210
these milliseconds back to Days,
30
30
00:01:24,210 --> 00:01:25,480
or two hours,
31
31
00:01:25,480 --> 00:01:27,653
or to whatever we really want.
32
32
00:01:28,500 --> 00:01:31,080
So let's actually now create a function
33
33
00:01:31,080 --> 00:01:33,000
that takes in two dates.
34
34
00:01:33,000 --> 00:01:35,380
And it's going to return the number of days
35
35
00:01:35,380 --> 00:01:37,773
that pass between these two dates.
36
36
00:01:39,170 --> 00:01:40,770
So days
37
37
00:01:40,770 --> 00:01:42,170
past,
38
38
00:01:42,170 --> 00:01:44,350
is going to be a function,
39
39
00:01:44,350 --> 00:01:46,790
or let's use an arrow function.
40
40
00:01:46,790 --> 00:01:48,913
So nice, one liner,
41
41
00:01:49,920 --> 00:01:51,763
so date one and date two.
42
42
00:01:53,160 --> 00:01:56,620
And then all we need to do is date two
43
43
00:01:56,620 --> 00:01:57,453
minus
44
44
00:01:57,453 --> 00:01:59,490
date, one.
45
45
00:01:59,490 --> 00:02:01,620
And so let's suppose that
46
46
00:02:02,790 --> 00:02:04,940
date two is later.
47
47
00:02:04,940 --> 00:02:06,960
But in case we do not want to suppose
48
48
00:02:06,960 --> 00:02:10,430
that we can simply take the absolute value here.
49
49
00:02:10,430 --> 00:02:11,830
And then it doesn't matter which
50
50
00:02:11,830 --> 00:02:14,653
of the dates here happened first in time.
51
51
00:02:15,520 --> 00:02:17,440
But for now, let's keep it like this.
52
52
00:02:17,440 --> 00:02:19,240
So I can show you later what I mean.
53
53
00:02:20,400 --> 00:02:23,900
So for now, let's actually also return this result.
54
54
00:02:23,900 --> 00:02:26,150
And then I will just call this function here.
55
55
00:02:27,880 --> 00:02:31,120
So calc, or actually, it's just calc Well,
56
56
00:02:31,120 --> 00:02:33,723
it should be calc a called calc.
57
57
00:02:34,650 --> 00:02:36,343
So this looks a bit nicer.
58
58
00:02:37,600 --> 00:02:39,403
So calc, days passed.
59
59
00:02:40,660 --> 00:02:43,293
And then let's just create two dates here.
60
60
00:02:45,290 --> 00:02:47,673
So let's use this one here.
61
61
00:02:48,930 --> 00:02:51,023
Maybe make it a little bit simpler.
62
62
00:02:52,540 --> 00:02:53,990
Let's say here,
63
63
00:02:53,990 --> 00:02:55,343
April 14.
64
64
00:02:56,840 --> 00:02:58,480
So this is the first date,
65
65
00:02:58,480 --> 00:03:00,713
the first that happens in time.
66
66
00:03:02,290 --> 00:03:04,220
And then the second date,
67
67
00:03:04,220 --> 00:03:06,060
let's just say,
68
68
00:03:06,060 --> 00:03:06,893
well,
69
69
00:03:06,893 --> 00:03:08,620
April 24.
70
70
00:03:08,620 --> 00:03:10,220
So this then makes it easy for us
71
71
00:03:10,220 --> 00:03:11,973
to visualize the result.
72
72
00:03:13,660 --> 00:03:17,578
And let's just call this const days one,
73
73
00:03:17,578 --> 00:03:19,633
and then login to the console.
74
74
00:03:23,060 --> 00:03:27,000
Alright, and so this gives us these milliseconds.
75
75
00:03:27,000 --> 00:03:29,450
And so now we just need to convert them.
76
76
00:03:29,450 --> 00:03:32,710
And this is similar to what we did,
77
77
00:03:32,710 --> 00:03:35,300
I think in one of the previous lectures.
78
78
00:03:35,300 --> 00:03:38,770
So we want to divide by 1000.
79
79
00:03:38,770 --> 00:03:41,653
And so this converts milliseconds to seconds,
80
80
00:03:42,650 --> 00:03:44,600
then that times 60,
81
81
00:03:44,600 --> 00:03:46,460
to convert it to minutes,
82
82
00:03:46,460 --> 00:03:49,380
then times 60 to convert it to hours,
83
83
00:03:49,380 --> 00:03:51,460
and then times 24,
84
84
00:03:51,460 --> 00:03:53,820
which converts it to days.
85
85
00:03:53,820 --> 00:03:58,820
And again, that's because there are 24 hours in a day.
86
86
00:03:59,160 --> 00:04:01,710
There are 60 minutes in one hour,
87
87
00:04:01,710 --> 00:04:04,030
60 seconds in one minute,
88
88
00:04:04,030 --> 00:04:07,363
and 1000 milliseconds in one second.
89
89
00:04:08,680 --> 00:04:11,350
And so now we get 10 days.
90
90
00:04:11,350 --> 00:04:13,250
And that makes sense.
91
91
00:04:13,250 --> 00:04:14,083
Right?
92
92
00:04:14,083 --> 00:04:15,650
So from April 24
93
93
00:04:15,650 --> 00:04:17,400
to April 14,
94
94
00:04:17,400 --> 00:04:19,500
we have exactly 10 days.
95
95
00:04:19,500 --> 00:04:21,010
Now what if here,
96
96
00:04:21,010 --> 00:04:22,210
we pass
97
97
00:04:22,210 --> 00:04:23,730
four.
98
98
00:04:23,730 --> 00:04:25,980
So now it's going to be the other way around.
99
99
00:04:27,190 --> 00:04:29,540
Right, so now we have minus 10.
100
100
00:04:29,540 --> 00:04:33,207
But we don't want that we always want it to be four
101
101
00:04:33,207 --> 00:04:35,440
and so that's what I meant earlier,
102
102
00:04:35,440 --> 00:04:39,030
where we can now simply take the absolute value of this.
103
103
00:04:39,030 --> 00:04:41,040
So math dot
104
104
00:04:41,040 --> 00:04:41,873
absolute.
105
105
00:04:45,070 --> 00:04:47,143
Which of the dates we pass in first.
106
106
00:04:48,030 --> 00:04:50,120
So if we now put four here
107
107
00:04:50,120 --> 00:04:52,200
and 14 here,
108
108
00:04:52,200 --> 00:04:55,030
then the result is still going to be 10.
109
109
00:04:55,030 --> 00:04:55,863
Great.
110
110
00:04:55,863 --> 00:04:58,440
So this works just really nice.
111
111
00:04:58,440 --> 00:05:01,590
Now if you need really pretty sighs calculations,
112
112
00:05:01,590 --> 00:05:04,390
for example, including time changes due
113
113
00:05:04,390 --> 00:05:06,520
to daylight saving changes,
114
114
00:05:06,520 --> 00:05:09,760
and other weird edge cases like that,
115
115
00:05:09,760 --> 00:05:14,420
then you should use a date library like moment dot js.
116
116
00:05:14,420 --> 00:05:15,370
And that's a library
117
117
00:05:15,370 --> 00:05:19,140
that's available for free for all JavaScript developers.
118
118
00:05:19,140 --> 00:05:21,420
But for something simple like this,
119
119
00:05:21,420 --> 00:05:23,310
we should be fine.
120
120
00:05:23,310 --> 00:05:25,230
Now, let's just consider
121
121
00:05:25,230 --> 00:05:29,200
that one of these days here also has some time.
122
122
00:05:29,200 --> 00:05:31,660
So let's say in this one here, it's also 10
123
123
00:05:31,660 --> 00:05:33,200
in the morning,
124
124
00:05:33,200 --> 00:05:34,470
or 10
125
125
00:05:34,470 --> 00:05:35,303
hours
126
126
00:05:35,303 --> 00:05:37,080
and eight minutes,
127
127
00:05:37,080 --> 00:05:38,260
doesn't really matter.
128
128
00:05:38,260 --> 00:05:41,450
But let's see what happens to the days now.
129
129
00:05:41,450 --> 00:05:44,680
And so Indeed, we now get 10.4.
130
130
00:05:44,680 --> 00:05:46,590
So we might not want that.
131
131
00:05:46,590 --> 00:05:47,423
And in this case,
132
132
00:05:47,423 --> 00:05:51,960
we can simply use math dot round on all of this.
133
133
00:05:51,960 --> 00:05:54,730
Okay, so keep that in mind.
134
134
00:05:54,730 --> 00:05:57,133
But I will just leave it like this.
135
135
00:05:58,010 --> 00:05:59,100
Alright.
136
136
00:05:59,100 --> 00:06:02,720
And now let's actually use this function to format
137
137
00:06:02,720 --> 00:06:04,920
and display or dates
138
138
00:06:04,920 --> 00:06:08,680
in a little bit nicer way here in our application.
139
139
00:06:08,680 --> 00:06:11,280
So basically, what I want to do is,
140
140
00:06:11,280 --> 00:06:13,860
if one movement happened today,
141
141
00:06:13,860 --> 00:06:16,490
then here instead of the current date,
142
142
00:06:16,490 --> 00:06:19,060
I want to display today,
143
143
00:06:19,060 --> 00:06:21,830
then if it happened yesterday,
144
144
00:06:21,830 --> 00:06:24,180
I want to write yesterday.
145
145
00:06:24,180 --> 00:06:27,500
And then if it happened, like a couple of days ago,
146
146
00:06:27,500 --> 00:06:29,010
then I want this to say,
147
147
00:06:29,010 --> 00:06:30,300
like two days ago
148
148
00:06:30,300 --> 00:06:32,000
or five days ago,
149
149
00:06:32,000 --> 00:06:33,530
instead of the date.
150
150
00:06:33,530 --> 00:06:35,220
And I'm sure you've seen this kind
151
151
00:06:35,220 --> 00:06:38,740
of stuff in many web applications that you use
152
152
00:06:38,740 --> 00:06:39,950
in your daily life.
153
153
00:06:39,950 --> 00:06:43,030
For example, if you post something on Facebook,
154
154
00:06:43,030 --> 00:06:45,207
and if you didn't watch it,
155
155
00:06:45,207 --> 00:06:46,202
the next day,
156
156
00:06:46,202 --> 00:06:47,890
it will say that you posted it yesterday,
157
157
00:06:47,890 --> 00:06:50,070
it's not going to display the exact date
158
158
00:06:50,070 --> 00:06:52,040
if it was just yesterday.
159
159
00:06:52,040 --> 00:06:54,030
And so that's a really nice use case
160
160
00:06:54,030 --> 00:06:56,023
of using a function like this.
161
161
00:06:57,260 --> 00:06:59,033
So let's grab this here.
162
162
00:07:00,420 --> 00:07:01,533
So I'm copying it.
163
163
00:07:03,010 --> 00:07:06,990
And then let's go to the display movements function,
164
164
00:07:06,990 --> 00:07:10,373
where we do actually print the date.
165
165
00:07:11,760 --> 00:07:15,250
Now, this is all kind of getting out of hand.
166
166
00:07:15,250 --> 00:07:18,000
So we have a lot of extra code here.
167
167
00:07:18,000 --> 00:07:19,733
And now we will add even more.
168
168
00:07:20,840 --> 00:07:22,860
So this function here,
169
169
00:07:22,860 --> 00:07:24,720
and even some more stuff.
170
170
00:07:24,720 --> 00:07:26,980
And so let's take all of this here,
171
171
00:07:26,980 --> 00:07:29,690
and actually create a new function,
172
172
00:07:29,690 --> 00:07:32,950
which will have the purpose of formatting this.
173
173
00:07:32,950 --> 00:07:33,783
Alright.
174
174
00:07:35,060 --> 00:07:36,810
So let's cut this here,
175
175
00:07:36,810 --> 00:07:40,660
as I just said, and create a function up here,
176
176
00:07:40,660 --> 00:07:43,210
just to make it a little bit more modular.
177
177
00:07:43,210 --> 00:07:44,050
All right.
178
178
00:07:44,050 --> 00:07:46,160
And then we can also reuse this function
179
179
00:07:46,160 --> 00:07:47,990
in some other place.
180
180
00:07:47,990 --> 00:07:49,490
Even though right now,
181
181
00:07:49,490 --> 00:07:50,323
in this case,
182
182
00:07:50,323 --> 00:07:51,890
we don't need it.
183
183
00:07:51,890 --> 00:07:53,000
I'm just doing this
184
184
00:07:53,000 --> 00:07:55,400
to split up the functionality a little bit
185
185
00:07:55,400 --> 00:07:57,623
across different places in our code.
186
186
00:07:59,240 --> 00:08:04,240
Okay, so this one receives a date as an input,
187
187
00:08:04,360 --> 00:08:05,790
and it will return
188
188
00:08:05,790 --> 00:08:08,150
the formatted date then,
189
189
00:08:08,150 --> 00:08:08,983
okay.
190
190
00:08:09,930 --> 00:08:11,770
So I'm copying all of this.
191
191
00:08:11,770 --> 00:08:15,440
But actually, this one should stay back here,
192
192
00:08:15,440 --> 00:08:16,683
where we got it from.
193
193
00:08:18,420 --> 00:08:19,793
And then also,
194
194
00:08:21,480 --> 00:08:24,630
so this, we need this variable back here,
195
195
00:08:24,630 --> 00:08:25,713
where it came from.
196
196
00:08:27,170 --> 00:08:28,240
So display date,
197
197
00:08:28,240 --> 00:08:31,250
because we use it down here as the value
198
198
00:08:31,250 --> 00:08:35,630
that we eventually want to print to the user interface.
199
199
00:08:35,630 --> 00:08:38,940
And so this one should actually be the result
200
200
00:08:38,940 --> 00:08:41,350
of calling or new function.
201
201
00:08:41,350 --> 00:08:43,393
So this format, movement date.
202
202
00:08:44,560 --> 00:08:47,130
So format, movement date,
203
203
00:08:47,130 --> 00:08:49,690
and here, we pass in the date variable
204
204
00:08:49,690 --> 00:08:51,463
that we just created up here.
205
205
00:08:53,012 --> 00:08:54,410
Alright,
206
206
00:08:54,410 --> 00:08:55,280
and so with this,
207
207
00:08:55,280 --> 00:08:58,750
we just exported the functionality here
208
208
00:08:58,750 --> 00:09:00,143
into a new function.
209
209
00:09:02,430 --> 00:09:04,180
So let's grab this
210
210
00:09:04,180 --> 00:09:07,453
and put it here at the top of the scope.
211
211
00:09:08,670 --> 00:09:11,970
And so for now, just to keep this working,
212
212
00:09:11,970 --> 00:09:13,853
let's return then this value.
213
213
00:09:15,220 --> 00:09:17,590
All right, and as you see,
214
214
00:09:17,590 --> 00:09:20,363
and let's just make sure by logging in.
215
215
00:09:22,070 --> 00:09:23,750
So as you see,
216
216
00:09:23,750 --> 00:09:26,890
the dates are now still being correctly printed.
217
217
00:09:26,890 --> 00:09:30,210
So we successfully exported this functionality here
218
218
00:09:30,210 --> 00:09:33,810
of displaying the dates into this function.
219
219
00:09:33,810 --> 00:09:37,270
And now we can just implement what I just said.
220
220
00:09:37,270 --> 00:09:40,400
So basically calculating how many days passed since
221
221
00:09:40,400 --> 00:09:42,460
the current date and between
222
222
00:09:42,460 --> 00:09:44,363
the date that we are working with.
223
223
00:09:46,610 --> 00:09:48,150
All right.
224
224
00:09:48,150 --> 00:09:49,860
So let's say
225
225
00:09:49,860 --> 00:09:51,253
const days,
226
226
00:09:52,370 --> 00:09:53,203
past
227
227
00:09:54,410 --> 00:09:56,640
and between.
228
228
00:09:56,640 --> 00:09:57,980
So between right now,
229
229
00:09:57,980 --> 00:09:59,713
there is a new date.
230
230
00:10:03,050 --> 00:10:05,000
And then the second date is the date
231
231
00:10:05,000 --> 00:10:07,393
that we just received here.
232
232
00:10:09,060 --> 00:10:12,010
So let's just print this to the console to see if it works.
233
233
00:10:13,950 --> 00:10:14,783
Okay.
234
234
00:10:16,650 --> 00:10:19,250
So what's all of this here?
235
235
00:10:19,250 --> 00:10:22,733
So we are printing here actually the wrong thing.
236
236
00:10:23,910 --> 00:10:25,703
So we want days past.
237
237
00:10:26,560 --> 00:10:28,423
So that was a mistake, obviously.
238
238
00:10:29,650 --> 00:10:31,550
But it's still not correct.
239
239
00:10:31,550 --> 00:10:32,383
And
240
240
00:10:33,830 --> 00:10:35,693
okay, I have another mistake.
241
241
00:10:36,540 --> 00:10:38,890
So probably you saw this already.
242
242
00:10:38,890 --> 00:10:42,863
So I did not even call the calc days past function.
243
243
00:10:44,050 --> 00:10:45,830
But now it should be good.
244
244
00:10:45,830 --> 00:10:48,973
And indeed, now we have our days here.
245
245
00:10:50,010 --> 00:10:51,140
Alright.
246
246
00:10:51,140 --> 00:10:54,500
And now let's actually round them.
247
247
00:10:54,500 --> 00:10:57,510
Okay, so that's what I was just saying earlier.
248
248
00:10:57,510 --> 00:11:00,593
So that we should probably round these dates.
249
249
00:11:01,780 --> 00:11:04,610
So we already learned how to do that.
250
250
00:11:04,610 --> 00:11:06,960
So math dot round,
251
251
00:11:06,960 --> 00:11:07,923
all of this.
252
252
00:11:09,453 --> 00:11:11,743
And so this looks a lot better now.
253
253
00:11:12,820 --> 00:11:14,800
Now, let's actually modify
254
254
00:11:14,800 --> 00:11:16,830
or dates here a little bit.
255
255
00:11:16,830 --> 00:11:18,570
And you should do the same.
256
256
00:11:18,570 --> 00:11:21,170
And what I'm going to do is to make
257
257
00:11:21,170 --> 00:11:25,060
one date yesterday, and then also a date,
258
258
00:11:25,060 --> 00:11:27,313
like three or four days ago.
259
259
00:11:29,070 --> 00:11:31,310
So see what's your current date,
260
260
00:11:31,310 --> 00:11:33,630
and then simply subtract one.
261
261
00:11:33,630 --> 00:11:35,920
So for me, it's August 2,
262
262
00:11:35,920 --> 00:11:38,760
so I'm going to use August 1,
263
263
00:11:38,760 --> 00:11:39,743
and then also,
264
264
00:11:40,890 --> 00:11:42,110
July
265
265
00:11:42,110 --> 00:11:43,670
28.
266
266
00:11:43,670 --> 00:11:46,090
And maybe another July here
267
267
00:11:46,090 --> 00:11:47,300
25,
268
268
00:11:47,300 --> 00:11:48,133
or maybe
269
269
00:11:48,133 --> 00:11:48,966
26.
270
270
00:11:50,470 --> 00:11:52,790
Okay, it's just so that we can see,
271
271
00:11:52,790 --> 00:11:56,000
like the yesterday or three days ago,
272
272
00:11:56,000 --> 00:11:57,970
or something like that.
273
273
00:11:57,970 --> 00:12:00,530
Alright, so do that now.
274
274
00:12:00,530 --> 00:12:03,603
And then let's go back here to or function.
275
275
00:12:04,486 --> 00:12:07,620
Now, then we want to implement some logic based
276
276
00:12:07,620 --> 00:12:08,873
on this day past.
277
277
00:12:10,260 --> 00:12:11,720
So if
278
278
00:12:11,720 --> 00:12:13,550
days past
279
279
00:12:13,550 --> 00:12:15,650
is zero,
280
280
00:12:15,650 --> 00:12:18,570
and so basically, that is,
281
281
00:12:18,570 --> 00:12:20,580
if we do something today,
282
282
00:12:20,580 --> 00:12:23,040
then actually the string that we want to print
283
283
00:12:23,040 --> 00:12:27,410
is not the current date, but instead today.
284
284
00:12:27,410 --> 00:12:30,500
All right, then if one day has passed,
285
285
00:12:30,500 --> 00:12:33,173
we want to return yesterday.
286
286
00:12:35,980 --> 00:12:37,070
Okay,
287
287
00:12:37,070 --> 00:12:38,240
next up,
288
288
00:12:38,240 --> 00:12:39,630
if
289
289
00:12:39,630 --> 00:12:43,990
well, let's say if the number of days past
290
290
00:12:43,990 --> 00:12:46,150
is within the last week.
291
291
00:12:46,150 --> 00:12:50,130
So that's less or equal seven,
292
292
00:12:50,130 --> 00:12:52,493
and then we will return the number of days.
293
293
00:12:54,850 --> 00:12:55,990
So days,
294
294
00:12:55,990 --> 00:12:56,823
past
295
295
00:12:58,530 --> 00:12:59,600
days,
296
296
00:12:59,600 --> 00:13:00,433
ago
297
297
00:13:01,770 --> 00:13:03,490
and else,
298
298
00:13:03,490 --> 00:13:05,100
so only if
299
299
00:13:05,100 --> 00:13:07,630
more than seven days have passed,
300
300
00:13:07,630 --> 00:13:11,163
only then we want to return the actual date.
301
301
00:13:13,510 --> 00:13:16,520
Okay, does that make sense?
302
302
00:13:16,520 --> 00:13:19,580
So let's save and see if it works.
303
303
00:13:19,580 --> 00:13:21,743
And yes, beautiful.
304
304
00:13:22,640 --> 00:13:24,850
So that's yesterday, five days ago,
305
305
00:13:24,850 --> 00:13:27,060
seven days ago.
306
306
00:13:27,060 --> 00:13:29,943
And then here are the other dates right here.
307
307
00:13:31,040 --> 00:13:32,670
So that's beautiful.
308
308
00:13:32,670 --> 00:13:33,960
Great.
309
309
00:13:33,960 --> 00:13:37,540
Let's now just do something.
310
310
00:13:37,540 --> 00:13:42,470
And actually, let's transfer like 500 to Jessica Davis.
311
311
00:13:42,470 --> 00:13:45,100
And that's gonna be the other way around.
312
312
00:13:45,100 --> 00:13:47,610
Jessica Davis, 500.
313
313
00:13:47,610 --> 00:13:52,293
And so now we should get one log here with today.
314
314
00:13:54,670 --> 00:13:57,590
Yes, indeed, there is today.
315
315
00:13:57,590 --> 00:14:00,330
And now if we log in as Jessica Davis,
316
316
00:14:00,330 --> 00:14:02,350
we should get the same.
317
317
00:14:02,350 --> 00:14:05,960
So now we have a deposit coming from today.
318
318
00:14:05,960 --> 00:14:08,810
And actually, we also have something from seven days ago.
319
319
00:14:10,000 --> 00:14:12,080
So great, that's amazing.
320
320
00:14:12,080 --> 00:14:13,310
If you ask me,
321
321
00:14:13,310 --> 00:14:16,640
that we are capable of now doing something like this,
322
322
00:14:16,640 --> 00:14:19,280
which looks like a real web application
323
323
00:14:19,280 --> 00:14:21,410
that you might use every day.
324
324
00:14:21,410 --> 00:14:22,890
All right.
325
325
00:14:22,890 --> 00:14:26,820
Now, maybe the logic here is a bit confusing with all
326
326
00:14:26,820 --> 00:14:28,350
of these returns.
327
327
00:14:28,350 --> 00:14:30,330
But that's completely normal.
328
328
00:14:30,330 --> 00:14:35,240
So as once we return, the function stops executing.
329
329
00:14:35,240 --> 00:14:38,950
And so these other returns will then never be reached.
330
330
00:14:38,950 --> 00:14:41,540
And so this is a pretty common technique.
331
331
00:14:41,540 --> 00:14:44,750
And actually, we wouldn't even need this else.
332
332
00:14:44,750 --> 00:14:46,910
So if I just remove this here,
333
333
00:14:46,910 --> 00:14:50,100
then all of this code will only be executed
334
334
00:14:50,100 --> 00:14:53,790
if all of these here are not executed.
335
335
00:14:53,790 --> 00:14:56,060
So only if all of these here are false.
336
336
00:14:56,060 --> 00:14:58,403
The rest of the code is even executed.
337
337
00:15:00,520 --> 00:15:02,623
So you see it works the exact same way.
338
338
00:15:05,590 --> 00:15:06,510
Awesome.
339
339
00:15:06,510 --> 00:15:09,330
So our application is even better now.
340
340
00:15:09,330 --> 00:15:11,260
And in the next two lectures,
341
341
00:15:11,260 --> 00:15:13,790
we will then do what I mentioned earlier,
342
342
00:15:13,790 --> 00:15:16,370
which is internationalization,
343
343
00:15:16,370 --> 00:15:19,930
which is to basically format these dates,
344
344
00:15:19,930 --> 00:15:21,620
and also these numbers here,
345
345
00:15:21,620 --> 00:15:24,883
according to each of the countries of these accounts.
26776
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.