Hey I'm back.
Yeah I forgot something that is kind of important to teach you guys that I said I was going to if you
remember when we were going through our our message cell we talked about the time stamp and that I was
going to get back to it.
And then I forgot to.
So yeah we're going to go over that right now.
So strap in we're going to talk about some ISO 86 or one dates.
All right.
So the format that the server gives the spec for dates is in the format called ISO 6 or 1.
And so it's an international standard you can do some googling on it.
But basically this is how it comes back.
We have.
I mean it's kind of recognizable.
Here's your standard year month and day.
Then we get into the hours minutes seconds and milliseconds.
So this wouldn't be so bad to work with because Apple actually has a built in I assume 86 or one date
for matter but the problem is the builtin one doesn't play well with milliseconds.
So if we had just been given this right here then it be no problem we'd be able to convert this string
into an ISO 86 or 1 date and then convert that directly to a date format that we're that we want to
use.
But because we have the Millicent's on here we're going to have to do a little bit of niggling with
the string chopping off the end and then reopening the Z.
So you know that's that's just just what we got to do so let's do it.
First thing we're doing we're going to unwrap our our data I'm going to say guard let ISO date equal
the message that time Stamm else we're going to return and then we're going to say we're going to do
is we want to turn this string into this string.
So we want to chop off these last five parts of the parts of the string OK.
So we're going to we're going to define we're going to use a function called substring to and basically
saying it'll take a string up to a specified index.
So we need to tell it where to stop.
So we're going to do that by saying that and equal ISO date dot index and to pick this one right here
which returns it indicates that a specified distance from the given index.
So the we're going to start at the end so I'm going to say I so take dot and index so we're saying start
here and then offset by 5 which in the Bakra start can sum minus 5.
So start at the end and then backtrack 5.
And now this right here is your index.
All right and then we're going to say ISO date is equal to ISO date dot substring up to and the end.
So now this guy is this right here.
We got rid of those last five by using substring to end.
All right.
So now we have a ISO 86 or one date format that is compatible with Apple's builtin formatter.
So now we can say let ISO four matter equal I guess.
Oh 86 so on do it formatter.
And we're going to change our string into an ISO 86 or one date and say let chapt date equal to ISO
formatter that date from string and the string is ISO date.
But we also need we have to have that Z on the ends and C ISO date dot appending a string and that string
is just the letter Z.
OK.
So basically through all of this we've turned this string into that string.
And that is something that we can use with this formatter.
So now we have an ISO 86 of one date not a string but an actual date.
And we can use another date formatted to turn that into something more readable for us.
OK so I say let.
New format for equal date formatter and I can say new form letter that date format.
And now we can customize how we want our dates to look.
And so what we're going to do is we're going to say m m m.
So this is going to give us the abbreviated month format.
I'm going to say for the day that we're going to get us the hour the minute and then the AM or PM.
All right.
So that's our that's what our formatters is going to spit us out.
So now we're going to say if let a final date is equal to chapt date which is an optional just because
of how the ISO formatter works then we're going to say let a final date equal new formatted dot string
from date.
So now we're getting her we're already converting from a date to a string.
OK.
And the date is final date.
And then we can actually set our time stamp label in our cell to this new labels that say time stamp
label.
That text is equal to final.
That you're going to save that.
And let's see here what do we got going on here.
This needs to be of our students.
This needs to be of bar right here guard bar.
There we go.
Let's get rid of this comment and let's try to run on this.
All right.
OK.
Two forty nine 256 15 looks like it is a work and it's work you
1:53 a.m..
That's right.
I'm still recording and editing videos at 2:00 a.m. for you guys.
All right.
Anyway so this is our final feature actually now so I won't forget you I told you I was going to teach
you how to do this so I am.
So now I guess this is the conclusion to the chat app so you guys have had fun and I'll see you around
Johnny B sign in now.