1
00:00:01,230 --> 00:00:06,150
So this time around, we want to do a couple of things, we want to change this numeric representation

2
00:00:06,150 --> 00:00:11,820
of the month to a textual representation of the month, and I want to get started building the necessary

3
00:00:11,820 --> 00:00:18,930
rows and they'll actually be tables and they'll be tables that are two rows, each one for the indicator

4
00:00:18,930 --> 00:00:24,360
for the current day of the month and one for a checkbox underneath it that will allow me to block a

5
00:00:24,360 --> 00:00:29,970
date or unblock a date or if there's already a reservation to display the reservation information for

6
00:00:29,970 --> 00:00:31,200
those particular dates.

7
00:00:31,860 --> 00:00:34,470
And they will have one column for each of the days of the month.

8
00:00:34,740 --> 00:00:39,350
Let's do this part first where we're changing this one to two in my case in December.

9
00:00:39,780 --> 00:00:46,110
So let's go back to our our code and think about how we might accomplish this in my handler.

10
00:00:46,350 --> 00:00:47,390
Where's my handler?

11
00:00:48,180 --> 00:00:50,700
They're they're OK in my handler.

12
00:00:50,730 --> 00:00:55,710
I know that now will always be set to at least the current month.

13
00:00:55,710 --> 00:00:59,360
It'll actually be set to the first day of the month that's being displayed.

14
00:00:59,970 --> 00:01:06,480
So what I could do is pass that value to my template using my data map.

15
00:01:06,480 --> 00:01:13,470
So let's create a data map here and I'll create it right here and I'll call it data is a sign the value

16
00:01:13,470 --> 00:01:17,370
of make a map string interface.

17
00:01:19,170 --> 00:01:27,660
And I'll put inside data with the label or the index look up of now the value of now and then down here

18
00:01:27,840 --> 00:01:30,570
where I actually render the template, I can pass that data.

19
00:01:32,870 --> 00:01:38,000
OK, so when I restart my application, I know that that will be available at the template, that's

20
00:01:38,000 --> 00:01:44,660
not terribly helpful yet because if I put data that put the value of now from data here, it's going

21
00:01:44,660 --> 00:01:49,040
to put the entire date with the time and all sorts of things that I don't actually want.

22
00:01:49,340 --> 00:01:57,230
What I want is some means of formatting now from the data map so that it shows the textual representation

23
00:01:57,230 --> 00:01:59,440
of the month here and the four digit year here.

24
00:01:59,690 --> 00:02:05,600
So what I probably should do is go to my render package and build a new function and make that available

25
00:02:05,600 --> 00:02:06,260
to my template.

26
00:02:06,260 --> 00:02:07,130
And I'm going to do that.

27
00:02:07,730 --> 00:02:09,760
It's very similar to human date.

28
00:02:10,160 --> 00:02:13,620
I could just say func and I'll call this format date.

29
00:02:14,930 --> 00:02:22,400
It will take two arguments t, which is of type timewarp time and F for format, which is just a string

30
00:02:22,400 --> 00:02:25,100
and that will be the format string and it will return a string.

31
00:02:26,390 --> 00:02:33,050
And all I have to do is say return t dot format with the format string, whatever.

32
00:02:33,050 --> 00:02:37,580
I pass it now I'll take this and put it in my function map.

33
00:02:37,580 --> 00:02:41,900
So it's available to my template and I'll call it format date with a lowercase F.

34
00:02:43,300 --> 00:02:45,670
All right, now let's restart the application.

35
00:02:47,440 --> 00:02:49,720
Stop it, start it, make sure it compiles.

36
00:02:51,560 --> 00:02:54,860
And it does now, if I go back to my.

37
00:02:56,730 --> 00:03:00,820
Calendar page right here at the very top of the content section.

38
00:03:00,840 --> 00:03:07,660
I'll pull that value now out of my data map, which I called now.

39
00:03:07,860 --> 00:03:08,820
That's how I look it up.

40
00:03:09,390 --> 00:03:14,850
And instead of doing this index string that this month, I can just say instead.

41
00:03:18,730 --> 00:03:25,240
Format date now, and I want to show the month of full representation of the month and according to

42
00:03:25,240 --> 00:03:31,390
the format string that Goh uses, he just used January and the same thing here.

43
00:03:31,390 --> 00:03:37,600
Instead of doing it that way, I can say format date now and now.

44
00:03:37,600 --> 00:03:42,170
I want the four digit representation of the year, which is 2006 according to that format stream.

45
00:03:42,580 --> 00:03:48,610
So if I go back here and reload this and if we did everything right, he will show December 2020 and

46
00:03:48,610 --> 00:03:51,430
if I go back November, go forward.

47
00:03:52,620 --> 00:03:53,280
Perfect.

48
00:03:53,310 --> 00:03:55,990
So that's much nicer now.

49
00:03:56,370 --> 00:04:02,910
Now I want to start showing one table or one line that consists of a table for each of the rooms to

50
00:04:02,910 --> 00:04:07,730
allow me to see the reservations and to block and unblock dates as I wish.

51
00:04:07,740 --> 00:04:09,000
And this is going to take a few steps.

52
00:04:09,000 --> 00:04:09,700
But let's get started.

53
00:04:09,900 --> 00:04:11,280
What's the very first thing I know?

54
00:04:11,280 --> 00:04:14,730
I'm going to need to know the number of days in a month.

55
00:04:14,890 --> 00:04:16,080
I'm going to need to know that.

56
00:04:16,290 --> 00:04:21,950
And I'm also going to have to have the rooms so I can show one calendar for each room.

57
00:04:23,100 --> 00:04:27,270
So let's get started back to my handlers over here.

58
00:04:29,830 --> 00:04:36,940
And we are in this handler, yes, this is the correct one admin reservations calendar, so we already

59
00:04:36,940 --> 00:04:40,260
have our data map and we have a string map.

60
00:04:40,300 --> 00:04:42,610
We're also going to need to pass an integer to it.

61
00:04:42,610 --> 00:04:49,880
So we may as well figure out how to get the number of days in a month and then put that in my map.

62
00:04:50,110 --> 00:04:53,440
So this is not quite as easy as you might think.

63
00:04:53,470 --> 00:04:59,520
What I want to do here is get the first and last days of the month, OK?

64
00:05:00,160 --> 00:05:05,640
And I'm going to do that by using a method that's built into the time package or a function called date.

65
00:05:05,650 --> 00:05:06,280
So I will.

66
00:05:06,430 --> 00:05:07,750
And that returns three things.

67
00:05:07,750 --> 00:05:14,950
And I'm going to get the current year and the current month and I'm going to ignore the current day

68
00:05:15,250 --> 00:05:19,520
and I'm going to get that from now using date.

69
00:05:19,750 --> 00:05:25,870
And if you look at what date does what it does, it returns the year, the month and the day, as if

70
00:05:26,110 --> 00:05:26,910
that's all that it does.

71
00:05:26,950 --> 00:05:29,590
So that gives me the current year in the current month, which is great.

72
00:05:30,250 --> 00:05:32,370
Now, I need to make sure I get the current location.

73
00:05:32,380 --> 00:05:40,600
So current location because different locations use different rules about Daylight Savings Time, so

74
00:05:40,600 --> 00:05:41,290
on and so forth.

75
00:05:41,300 --> 00:05:45,820
So what I'm going to do is just say that that's equal to now, location, whatever the current location

76
00:05:45,820 --> 00:05:47,590
is for now.

77
00:05:47,650 --> 00:05:52,000
And I think we set that to time, that UTC, which is just fine for our purposes in this course, if

78
00:05:52,000 --> 00:05:56,670
you need to a specific location, then you would have to, of course, set that up yourself.

79
00:05:56,680 --> 00:06:00,130
But right now, UTC Universal Time will work just perfectly.

80
00:06:01,450 --> 00:06:03,670
Now I need to get the first of the month.

81
00:06:04,120 --> 00:06:12,610
First of month will be a variable that's going to be assigned the value of time dot date and it will

82
00:06:12,610 --> 00:06:15,130
be current year, which I just got.

83
00:06:17,510 --> 00:06:25,730
Current month, which I just got the first day of the month, then hours or days, hours, minutes,

84
00:06:25,730 --> 00:06:30,370
seconds, nanoseconds, which I'll leave at zero for all of them and my current location.

85
00:06:31,250 --> 00:06:37,400
So I just set first of month to whatever the current year is, whatever the current month is, and whatever

86
00:06:37,400 --> 00:06:38,270
the current day is.

87
00:06:38,300 --> 00:06:42,020
Now, I could have used now, which has pretty much the same thing, but I'm just showing you how this

88
00:06:42,020 --> 00:06:44,270
works and this makes it very much a much more readable.

89
00:06:44,720 --> 00:06:46,010
So that's the first of the month.

90
00:06:46,430 --> 00:06:53,330
The last of the month will be assigned the value of 1st of month.

91
00:06:54,170 --> 00:07:02,210
And I'm going to add a date and I'm going to add New Years one month and take one day off, which will

92
00:07:02,210 --> 00:07:06,860
get me to the last day of the current month, which is exactly what I want.

93
00:07:07,340 --> 00:07:07,480
Now.

94
00:07:07,490 --> 00:07:13,430
I want to store that that date, which will be the number of days in the current month.

95
00:07:13,610 --> 00:07:16,700
I want to store that in an intermap and pass that to my template.

96
00:07:16,700 --> 00:07:23,720
So let's create an app map, make a map, string it.

97
00:07:25,190 --> 00:07:33,620
And in that intermap, let's store using this as our lookup days in month.

98
00:07:35,840 --> 00:07:42,270
That's going to be equal to last of month and call in the built in function day, which returns in it.

99
00:07:42,650 --> 00:07:48,330
So if there's 31 days in the month, then days and month in it, Matt will have the value of 31.

100
00:07:48,440 --> 00:07:50,200
If there's twenty eight, it'll have twenty eight.

101
00:07:51,320 --> 00:07:53,180
And then of course we need to pass our intermap

102
00:07:55,940 --> 00:07:57,430
and that will be equal to EMAP.

103
00:07:58,280 --> 00:07:59,170
So we have that.

104
00:07:59,270 --> 00:08:00,480
Those are the days of the month.

105
00:08:00,500 --> 00:08:03,180
We also need to get the rooms and we know how to do that.

106
00:08:03,200 --> 00:08:03,860
That's pretty easy.

107
00:08:03,890 --> 00:08:05,210
So let's just look up our rooms.

108
00:08:05,660 --> 00:08:06,350
Rooms.

109
00:08:06,350 --> 00:08:10,070
Error is a sign the value of M DB all rooms.

110
00:08:16,230 --> 00:08:17,670
We don't have an all rooms function yet.

111
00:08:17,730 --> 00:08:19,260
Well, let's go make one that's pretty easy.

112
00:08:20,490 --> 00:08:22,680
I thought we had an all rooms function, but apparently we don't.

113
00:08:22,710 --> 00:08:31,950
So let's go to postgrads and let's create a funk m postgrads debe repoll and we'll call it Ballroom's

114
00:08:33,120 --> 00:08:40,710
and it takes no parameters and it returns a slice of model's room and potentially an error.

115
00:08:41,460 --> 00:08:48,960
OK, and let's get a context and copy and paste that to save some typing so we need a variable to hold

116
00:08:48,960 --> 00:08:49,710
our result.

117
00:08:49,710 --> 00:08:58,080
So we'll create a ver rum's which will be of type slice of models doldrum and let's write a query.

118
00:08:58,230 --> 00:09:05,070
Query is a sign the value of select Edek room name created at.

119
00:09:05,160 --> 00:09:06,350
There's not much information in a room.

120
00:09:06,360 --> 00:09:14,490
So this is really short and updated at from rooms order by room name.

121
00:09:15,630 --> 00:09:22,920
Yep, that looks right, and I will just quickly get our query and execute it so Rose and potentially

122
00:09:22,920 --> 00:09:28,080
an error as a sign the value of MGB query context.

123
00:09:31,450 --> 00:09:39,280
Of the context of our query, check for an error, if error is not equal to nil return rooms, which

124
00:09:39,280 --> 00:09:40,690
will be empty and the error.

125
00:09:44,090 --> 00:09:50,750
Otherwise, for a deferral close, they want to forget that defer rose close

126
00:09:53,150 --> 00:09:57,290
for rows, next, we loop through whatever we get back from the database.

127
00:09:57,560 --> 00:10:03,310
We create a new variable of our R.M., which will be of type models room and I.

128
00:10:03,310 --> 00:10:06,500
We scan our values into the variable.

129
00:10:06,500 --> 00:10:16,010
We just created rows dot scan and will it will be our emerg ID and then I'll just duplicate that three

130
00:10:16,010 --> 00:10:22,670
more times and change it to remain created and updated at.

131
00:10:27,310 --> 00:10:35,920
Check for our error if error is not equal to nil return rooms, error otherwise appended to the slice.

132
00:10:36,430 --> 00:10:41,650
So rooms equals append rooms room.

133
00:10:43,580 --> 00:10:51,290
And then finally, if we have an error and it's if our error is equal to Rosewarne error.

134
00:10:53,890 --> 00:11:03,490
And air is not equal to nil, then return rooms and air, otherwise return rooms and nil.

135
00:11:03,880 --> 00:11:05,800
OK, so that's created.

136
00:11:05,800 --> 00:11:11,590
Let's copy the whole thing and put it in our test tube repo copy and test repo.

137
00:11:13,550 --> 00:11:17,450
And I'll just paste it here, give it the correct receiver.

138
00:11:20,910 --> 00:11:26,640
Save the variable, the declaration, and delete everything except for the return, which will allow

139
00:11:26,640 --> 00:11:30,570
us to compile this, and then we'll need to add this to our repository.

140
00:11:30,590 --> 00:11:37,680
So let's copy this, open the repository and pasted in here all rooms.

141
00:11:38,070 --> 00:11:40,740
OK, so let's go back to our handlers.

142
00:11:42,810 --> 00:11:45,340
And now we should be able to use that function and we can.

143
00:11:45,720 --> 00:11:50,160
So we've got our rooms and we check for an error if error is not equal to nil.

144
00:11:53,800 --> 00:11:57,970
And I'll just go helper's server error w an error and return.

145
00:12:00,100 --> 00:12:01,710
So now we have our rooms.

146
00:12:01,870 --> 00:12:02,320
Let's go.

147
00:12:02,320 --> 00:12:06,490
Data rooms equals rooms.

148
00:12:08,820 --> 00:12:14,250
So now we've got our rooms past to that and we have our number of days in the month, so we're actually

149
00:12:14,250 --> 00:12:19,700
at the point, I think, where we can start to generate our tables, but we have one problem.

150
00:12:19,950 --> 00:12:24,990
So let's go back and look at this and think about what we want here, what we want on this page right

151
00:12:24,990 --> 00:12:25,180
away.

152
00:12:25,200 --> 00:12:31,080
I want Generals' quarters, then I want to have a row the a table that has two rows, one with the the

153
00:12:31,080 --> 00:12:35,190
top level being the days of the month from one to the last day of the month.

154
00:12:35,520 --> 00:12:40,200
And then underneath I just right now I want to put an empty checkbox and I worry about populating that

155
00:12:40,200 --> 00:12:44,990
with checks when we have a block for a date or populating when we have reservations, whatever.

156
00:12:45,030 --> 00:12:46,920
Right now I just want to get it showing up.

157
00:12:48,540 --> 00:12:49,560
How am I going to do that?

158
00:12:50,160 --> 00:12:56,880
Because as far as I know, there is no functionality built into the go templating system that allows

159
00:12:56,880 --> 00:12:58,290
you to do a simple for loop.

160
00:12:58,290 --> 00:13:01,860
So for one two number of days in month, do the following.

161
00:13:01,860 --> 00:13:03,180
That doesn't exist.

162
00:13:03,180 --> 00:13:05,430
And it seems like a glaring omission.

163
00:13:05,910 --> 00:13:11,160
And I think one of the reasons that they left it out is it's so easy to do it yourself.

164
00:13:11,190 --> 00:13:15,510
So let's go back to our render package and create a new function render package.

165
00:13:15,690 --> 00:13:19,320
I need to build a function that allows me to iterate between two dates.

166
00:13:19,320 --> 00:13:24,450
So let's find our render rendered Dutko, OK?

167
00:13:24,930 --> 00:13:29,340
And I'm going to create a new function right here and I will call this func iterate.

168
00:13:32,080 --> 00:13:38,650
And it will take one parameter, which I'm going to call count, and it's just an ant and it returns

169
00:13:38,710 --> 00:13:44,380
a slice of ants, and because I'm returning a slice, that's something I can iterate over.

170
00:13:44,560 --> 00:13:46,300
And it's really, really easy to do this.

171
00:13:46,400 --> 00:13:53,940
So let's create a variable variety of type int and var items, which is another variable.

172
00:13:53,980 --> 00:13:55,210
This will be a slice of it.

173
00:13:56,050 --> 00:14:01,720
And all I have to do now is write the for loop that I wish I could write on my go template for I equals

174
00:14:01,720 --> 00:14:02,200
zero.

175
00:14:03,010 --> 00:14:04,510
I is less than count.

176
00:14:06,750 --> 00:14:07,740
I plus, plus.

177
00:14:09,740 --> 00:14:20,240
And then items equals append items, hi, and I just return that return items, give this a comment,

178
00:14:22,820 --> 00:14:33,530
iterate returns a slice of INTs starting at one, going to count and count as the variable that I've

179
00:14:33,530 --> 00:14:34,160
posted here.

180
00:14:34,160 --> 00:14:39,310
So if I pass it 10, I'll get a slice of INTs starting at 1:00 and going to ten.

181
00:14:40,040 --> 00:14:43,460
And then of course I need to add this to my funk map so I have access to it.

182
00:14:43,460 --> 00:14:44,930
So I'll create a new function.

183
00:14:44,930 --> 00:14:47,540
I'll call iterate, that's what I'll call it, the goal line template.

184
00:14:47,930 --> 00:14:48,800
And it's just iterate.

185
00:14:49,010 --> 00:14:52,910
And this needs a comma, of course, and I should have access to it now.

186
00:14:52,910 --> 00:14:59,800
So if I go back to my admin reservations calendar page, then I can actually start to build my, my,

187
00:15:03,270 --> 00:15:05,140
my tables the way I want them to look.

188
00:15:05,150 --> 00:15:07,900
And of course, I want them to come after the clear fix.

189
00:15:07,980 --> 00:15:08,960
It's going to be down here.

190
00:15:09,500 --> 00:15:13,070
And I just want to, first of all, go through my rooms.

191
00:15:13,070 --> 00:15:20,240
So let's make it easier to write this by getting our rooms variable out of the data map.

192
00:15:22,100 --> 00:15:23,290
And I called it rooms.

193
00:15:23,300 --> 00:15:25,460
So now I have a variable that holds my rooms.

194
00:15:25,460 --> 00:15:32,030
So down here after the clear fix, I should be able to say Range Rum's.

195
00:15:35,750 --> 00:15:36,560
And put it in there.

196
00:15:37,010 --> 00:15:40,130
OK, so let's just make sure this works to start with.

197
00:15:40,160 --> 00:15:46,990
OK, so I will just put DOT Room name and let's stop the application.

198
00:15:47,270 --> 00:15:48,800
We're not using our iterate function yet.

199
00:15:48,800 --> 00:15:53,200
We're just making sure that everything compiles and then we have data when we think we should have data.

200
00:15:53,630 --> 00:15:59,240
So I should see the rooms here, one name after another, and I do OK, so I have access to that, which

201
00:15:59,240 --> 00:15:59,660
is great.

202
00:16:00,620 --> 00:16:03,590
So I don't want to actually display the name here yet like that.

203
00:16:03,770 --> 00:16:05,150
I want to do it this way.

204
00:16:05,690 --> 00:16:11,870
Let's grab some information I know I'm going to need I'm going to need at some point inside a loop a

205
00:16:11,870 --> 00:16:12,400
remedy.

206
00:16:12,410 --> 00:16:19,610
So I'll save room ID is assigned the value of ID and that's from each individual room.

207
00:16:19,640 --> 00:16:22,370
So now if I need it, I have access to the remedy.

208
00:16:23,270 --> 00:16:30,290
And let's put in our room name as an H four, which isn't too big, but is big enough to be obviously

209
00:16:30,290 --> 00:16:30,710
a title.

210
00:16:31,020 --> 00:16:39,350
OK, and underneath that I actually want to have a table and this will be a table that needs to be visible

211
00:16:39,350 --> 00:16:40,100
in every device.

212
00:16:40,130 --> 00:16:49,550
So I'm going to make it a mobile friendly table by putting this in a div div class equals table responsive.

213
00:16:49,770 --> 00:16:55,490
And this is actually built into bootstrap and it allows you to scroll to the left in the right if the

214
00:16:55,490 --> 00:16:57,730
table is too big for the current viewport.

215
00:16:57,740 --> 00:17:02,150
So if you're looking at this on a phone, you can just drag the whole table to the left and to the right,

216
00:17:02,150 --> 00:17:03,320
and that will be very helpful.

217
00:17:04,070 --> 00:17:09,610
Now I actually put the table inside of that div table class equals table table.

218
00:17:09,620 --> 00:17:13,510
I'm going to make it a table bordered so it has nice lines around all the cells.

219
00:17:13,520 --> 00:17:18,560
And again, that's built into bootstrap and I'll make it a small table, make it as compact as I can.

220
00:17:18,650 --> 00:17:21,260
OK, so there's my table inside of that.

221
00:17:21,260 --> 00:17:27,470
I'm not going to have a ticket because I don't want a had my header is actually going to be a row that

222
00:17:27,470 --> 00:17:32,420
is going to have in each cell for that first row the number the current day of the month.

223
00:17:32,420 --> 00:17:37,040
So starts one, then two, then three right up to thirty one for December for example.

224
00:17:37,550 --> 00:17:43,340
So I'll put a TR in there, but I want that TR to be slightly different than the rest of the table,

225
00:17:43,340 --> 00:17:47,690
which is only one more row, and I'm going to give it the class of table dark, which will give it a

226
00:17:47,690 --> 00:17:49,100
nice dark background.

227
00:17:49,730 --> 00:17:55,220
And inside of that I have to range over my days in the month.

228
00:17:55,490 --> 00:17:57,350
So what do we call days in the month?

229
00:17:57,360 --> 00:17:58,520
Let's go back to our handler.

230
00:17:58,520 --> 00:17:59,990
I think I called it days and months.

231
00:18:00,110 --> 00:18:02,030
So let's find our handlers right here.

232
00:18:02,690 --> 00:18:04,220
And where did I put it?

233
00:18:04,220 --> 00:18:08,900
Yes, I called it days and month and I put that days and month is in my intermap.

234
00:18:08,900 --> 00:18:12,290
So let's go back to our calendar page and let's just pull that out right up here.

235
00:18:12,470 --> 00:18:22,610
And I'll call this dim for days in month is a sign the value of index intermap days in month.

236
00:18:22,670 --> 00:18:25,180
So now I have this all stored in a variable.

237
00:18:25,190 --> 00:18:30,740
So in February of anon leap here, this demand will be equal to twenty eight for every other year.

238
00:18:30,770 --> 00:18:32,750
If it's November, it'll be equal to thirty.

239
00:18:32,990 --> 00:18:35,540
And here's where I can range over the.

240
00:18:41,260 --> 00:18:44,800
And OK, so what's going to be in there?

241
00:18:44,830 --> 00:18:50,860
Well, let's try this, let's try TRD because, you know, it's going to be at a table cell, which

242
00:18:50,860 --> 00:18:54,310
is TRD and I'll centera just to make it look nice.

243
00:18:54,670 --> 00:18:57,580
Class equals text center.

244
00:18:58,690 --> 00:19:02,910
And I'll I put in here is well, what am I going to put in here?

245
00:19:02,920 --> 00:19:05,120
It'll be the current piece of data.

246
00:19:05,950 --> 00:19:06,910
Let's see how that works.

247
00:19:07,420 --> 00:19:11,950
Let's go back and reload this page and see what happens.

248
00:19:11,950 --> 00:19:12,880
And it crashed.

249
00:19:13,150 --> 00:19:14,080
What did it crash with.

250
00:19:14,320 --> 00:19:16,210
Exciting content at demn range.

251
00:19:16,210 --> 00:19:18,250
Can't iterate over thirty one.

252
00:19:18,630 --> 00:19:19,050
Right.

253
00:19:19,420 --> 00:19:20,490
That's what I forgot to do.

254
00:19:20,980 --> 00:19:26,170
So we have that demn we actually need to not iterate over dim instead.

255
00:19:26,170 --> 00:19:27,910
We want to iterate over.

256
00:19:28,460 --> 00:19:29,350
Let me see here.

257
00:19:32,600 --> 00:19:39,590
It Radim, we want to pass it 31 to that function we just wrote and we want to store that value in index

258
00:19:39,950 --> 00:19:43,930
and then from here I'm going to show the index.

259
00:19:44,720 --> 00:19:46,070
So let's start our application.

260
00:19:47,720 --> 00:19:54,770
Because it crashed and go back here and try this again, it looks almost right, except the last time

261
00:19:54,770 --> 00:19:57,880
I checked, there is no zero at the beginning of the month.

262
00:19:58,010 --> 00:20:00,200
There's no zeroth of December.

263
00:20:00,290 --> 00:20:04,010
So what I need to do is to add one value to whatever I get.

264
00:20:05,010 --> 00:20:06,740
OK, that's a good start.

265
00:20:07,670 --> 00:20:08,780
How am I going to do that?

266
00:20:08,810 --> 00:20:16,660
Well, let's go back and find our functions here under repository, under rendered.

267
00:20:17,750 --> 00:20:24,350
And again, this is something you would think would be built into the default package or the standard

268
00:20:24,350 --> 00:20:25,940
library for go templates.

269
00:20:26,060 --> 00:20:26,900
But it's not.

270
00:20:27,320 --> 00:20:28,520
And it's really easy to write.

271
00:20:28,700 --> 00:20:30,590
So we'll create a function here.

272
00:20:36,150 --> 00:20:45,180
Called ad and ad will take to it's A and B of type it and it will return an end and all I have to do

273
00:20:45,180 --> 00:20:52,110
is return A plus B and then add that up here.

274
00:20:54,770 --> 00:21:00,010
OK, so that will give us the ability to add something to it, to add to it together.

275
00:21:00,020 --> 00:21:03,840
So let's go back to our calendar page and see what we're going to do here.

276
00:21:03,890 --> 00:21:06,620
We're going to find that index instead of just returning.

277
00:21:06,620 --> 00:21:13,040
Index will return and index and one which should add one to every day of the month.

278
00:21:13,120 --> 00:21:17,750
OK, the other thing I noticed when I look at this, so these are awfully close together.

279
00:21:17,750 --> 00:21:23,030
So let's put some spacing above the title for each room since we're here anyway, let's do it right

280
00:21:23,030 --> 00:21:23,350
now.

281
00:21:23,450 --> 00:21:28,140
Each four would go class margin top say four.

282
00:21:28,430 --> 00:21:29,390
See what that looks like.

283
00:21:29,810 --> 00:21:32,930
So let's stop our application, start our application.

284
00:21:32,930 --> 00:21:38,830
So don't be aware of that ad function we just put in there and reload this and that looks better.

285
00:21:38,840 --> 00:21:40,930
So there are 31 days in January.

286
00:21:40,970 --> 00:21:42,110
Let's go back to November.

287
00:21:43,140 --> 00:21:49,100
Our December December has 31 and 30 for November, 31 for October.

288
00:21:49,170 --> 00:21:49,890
Perfect.

289
00:21:50,220 --> 00:21:52,050
OK, so that part works.

290
00:21:52,420 --> 00:21:56,540
Now let's go and do the same thing for the second row of our table.

291
00:21:57,540 --> 00:22:03,440
So here is our second row and our second row is going to be another TD.

292
00:22:04,530 --> 00:22:10,110
And inside of that four right now, I'll give it again in the class of Texaco's center class equals

293
00:22:10,110 --> 00:22:11,380
text center.

294
00:22:13,290 --> 00:22:15,000
Let's just put a checkbox in there.

295
00:22:15,060 --> 00:22:18,600
Input type equals checkbox.

296
00:22:18,870 --> 00:22:22,110
And that's all I'm going to do right now just to make sure this looks right.

297
00:22:24,010 --> 00:22:29,200
And it doesn't because I forgot to change over it once again, range index.

298
00:22:31,560 --> 00:22:32,970
And close that range.

299
00:22:35,210 --> 00:22:40,150
Save that, reload it not quite right, but I do wrong.

300
00:22:41,350 --> 00:22:44,740
Oh, the Rangers outside the TDs having a bad day.

301
00:22:44,770 --> 00:22:47,950
I think I need to make a coffee and I'll do that before I start the next lecture.

302
00:22:50,610 --> 00:22:57,120
All right, let's try this one more time, and now I should see a checkbox under every day of the month

303
00:22:57,330 --> 00:22:58,440
that looks better.

304
00:22:59,640 --> 00:23:05,850
So the next step will be to wrap this entire thing in a form tag and create the handler to handle a

305
00:23:05,850 --> 00:23:10,000
post from this your you admin reservations dash calendar.

306
00:23:10,320 --> 00:23:17,070
And when I check different dates, I want that to turn blocks on.

307
00:23:17,160 --> 00:23:22,590
If a date is checked, nobody can book make a reservation for those particular dates.

308
00:23:23,050 --> 00:23:27,590
And if I want to get rid of a block, all I would do is uncheck them and click save.

309
00:23:27,600 --> 00:23:32,160
So I have to create a save button too and we'll take care of that in the next two or three lectures

310
00:23:32,160 --> 00:23:33,980
because there's quite a few steps to make that happen.
