-
Notifications
You must be signed in to change notification settings - Fork 48
/
227.srt
4087 lines (3002 loc) · 89.4 KB
/
227.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:00:00.506 --> 00:00:09.496 A:middle
[ Silence ]
00:00:09.996 --> 00:00:12.926 A:middle
>> Hello and welcome to
Solutions to Common Date
00:00:12.926 --> 00:00:15.326 A:middle
and Time Challenges,
I'm Chris Kane.
00:00:16.036 --> 00:00:20.916 A:middle
Now, two years ago at WWDC
2011 I gave a very similar talk
00:00:21.356 --> 00:00:25.336 A:middle
called Performing Calendrical
Calculations and I--
00:00:25.536 --> 00:00:29.556 A:middle
you can go on the develop site
at apple.com and find the video
00:00:29.556 --> 00:00:31.256 A:middle
for that and watch that too.
00:00:31.406 --> 00:00:35.146 A:middle
But I promise for this talk
I have some all new content.
00:00:35.146 --> 00:00:37.006 A:middle
So, this talk is not really--
00:00:37.096 --> 00:00:40.506 A:middle
not just a duplication
of that talk 2 years ago.
00:00:40.506 --> 00:00:43.386 A:middle
What I'm going to be
doing today is I'm going
00:00:43.386 --> 00:00:46.636 A:middle
to give you a brief introduction
to the calendar APIs,
00:00:47.636 --> 00:00:53.006 A:middle
these are the APIs that one
uses to do calendar operations,
00:00:53.796 --> 00:00:55.556 A:middle
calendrical calculations
if you will
00:00:55.626 --> 00:00:57.366 A:middle
and I'll be explaining that.
00:00:57.366 --> 00:01:00.846 A:middle
Then the bulk of
the talk is going
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:00:57.366 --> 00:01:00.846 A:middle
Then the bulk of
the talk is going
00:01:00.846 --> 00:01:03.966 A:middle
to be spent covering
several common tasks
00:01:03.966 --> 00:01:07.146 A:middle
that we see people doing over
and over again, and I'm going
00:01:07.146 --> 00:01:10.186 A:middle
to talk about how I
would go about, you know,
00:01:10.186 --> 00:01:12.066 A:middle
doing those kinds of operations.
00:01:12.846 --> 00:01:17.036 A:middle
Now, my examples are going to
use some new methods that are
00:01:17.136 --> 00:01:24.986 A:middle
in Mavericks OS X, Mavericks,
but not yet in iOS watch
00:01:24.986 --> 00:01:29.836 A:middle
for a future update in iOS
for those APIs to appear.
00:01:29.996 --> 00:01:34.056 A:middle
They're not here in your
seed for example, iOS seed.
00:01:35.476 --> 00:01:38.026 A:middle
Finally, I'm going to wrap
up with just a few words
00:01:38.026 --> 00:01:41.686 A:middle
about testing calendar
calculations.
00:01:42.656 --> 00:01:46.166 A:middle
And then give you some more
information about where to look
00:01:46.816 --> 00:01:50.436 A:middle
for additional resources
and stuff like that.
00:01:51.006 --> 00:01:51.956 A:middle
So, let's dive in.
00:01:52.286 --> 00:01:56.196 A:middle
So, when I talk about the
calendar APIs, I'm referring
00:01:56.196 --> 00:02:01.486 A:middle
to just these 4 classes here,
NSDate, NSDateComponets,
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:01:56.196 --> 00:02:01.486 A:middle
to just these 4 classes here,
NSDate, NSDateComponets,
00:02:01.896 --> 00:02:04.156 A:middle
NSCalendar and NSTimeZone.
00:02:05.066 --> 00:02:07.256 A:middle
Now, if you wanted to present
information to the user
00:02:07.256 --> 00:02:09.205 A:middle
on the screen like
display a date,
00:02:09.205 --> 00:02:12.016 A:middle
you would use a class
called NSDate Formatter.
00:02:12.016 --> 00:02:14.806 A:middle
I'm not going to be talking
about NSDate formatter
00:02:14.806 --> 00:02:18.246 A:middle
in this particular talk
but you can go look about--
00:02:18.246 --> 00:02:20.076 A:middle
look at the documentation
00:02:20.076 --> 00:02:24.906 A:middle
for NSDate formatter
online or an Xcode.
00:02:25.046 --> 00:02:26.716 A:middle
So, what is an NSDate?
00:02:27.556 --> 00:02:30.536 A:middle
Well, NSDate is a very
simple value object
00:02:30.846 --> 00:02:35.596 A:middle
that has just one property
which is a floating point number
00:02:35.816 --> 00:02:39.146 A:middle
of seconds relative
to our reference date.
00:02:39.706 --> 00:02:41.506 A:middle
So, basically it
just got one property
00:02:41.566 --> 00:02:45.426 A:middle
which is a double floating point
number, happens to be a double
00:02:45.426 --> 00:02:47.846 A:middle
in this case and
that's stores the number
00:02:47.846 --> 00:02:53.596 A:middle
of seconds either before or
after our reference date.
00:02:54.036 --> 00:02:57.046 A:middle
So, at this point I'm going
to introduce this graphic
00:02:57.046 --> 00:02:57.996 A:middle
which I'm going
00:02:57.996 --> 00:03:01.176 A:middle
to use throughout the
talk, this is our timeline.
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:02:57.996 --> 00:03:01.176 A:middle
to use throughout the
talk, this is our timeline.
00:03:01.176 --> 00:03:04.856 A:middle
Now, I'm going to add a
boss here to the timeline,
00:03:04.856 --> 00:03:09.506 A:middle
this little knob in the middle
and that's going to refer
00:03:09.506 --> 00:03:11.556 A:middle
in this particular case
to our reference date.
00:03:12.246 --> 00:03:15.206 A:middle
So, we're a little bit after
our reference date right now
00:03:15.656 --> 00:03:16.956 A:middle
that the actual value
00:03:16.956 --> 00:03:18.936 A:middle
of the reference date
doesn't really matter,
00:03:19.526 --> 00:03:23.766 A:middle
it's in 2001 for-- in the
Gregorian calendar as it happens
00:03:23.766 --> 00:03:27.316 A:middle
so it's a little
ways in the past
00:03:27.556 --> 00:03:29.266 A:middle
but so the numbers right now
00:03:29.446 --> 00:03:34.226 A:middle
that an NSDate their
storing is a bit--
00:03:34.226 --> 00:03:35.716 A:middle
the numbers are positive.
00:03:36.146 --> 00:03:41.046 A:middle
We're about 12 years after 2001
00:03:41.146 --> 00:03:43.826 A:middle
and so the numbers
are slightly positive
00:03:43.826 --> 00:03:45.826 A:middle
but because this is a
floating point number.
00:03:45.826 --> 00:03:49.116 A:middle
These numbers cans be very large
and, you know, go often to the,
00:03:49.116 --> 00:03:54.736 A:middle
you know, far future and refer
to dates into the far past.
00:03:54.986 --> 00:03:59.786 A:middle
They're about, what, 31 million
seconds or so in every year
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:04:00.206 --> 00:04:04.396 A:middle
so of course after 12 years
there must be over, what,
00:04:04.666 --> 00:04:09.336 A:middle
360 million seconds that
are being as value seconds,
00:04:09.336 --> 00:04:11.956 A:middle
that are being stored in
every NSDate for dates
00:04:11.956 --> 00:04:13.266 A:middle
that around the current time.
00:04:14.296 --> 00:04:19.116 A:middle
So, these numbers are very large
of course and we don't work
00:04:19.116 --> 00:04:22.786 A:middle
with them numbers like
360 million seconds,
00:04:22.856 --> 00:04:26.406 A:middle
that's 2001 as humans and
I'll be getting to that
00:04:26.406 --> 00:04:28.276 A:middle
in a second what we do instead.
00:04:28.836 --> 00:04:31.386 A:middle
Now, in NSDate, I want
00:04:31.486 --> 00:04:34.836 A:middle
to emphasize represents
both a time and a date.
00:04:35.386 --> 00:04:37.726 A:middle
It has the word date
in there in the name
00:04:37.886 --> 00:04:40.316 A:middle
but since it is a
number of seconds
00:04:40.726 --> 00:04:45.456 A:middle
since the reference date, it
is both a date and a time.
00:04:45.456 --> 00:04:48.546 A:middle
It refers to a specific
moment in time really.
00:04:49.166 --> 00:04:54.076 A:middle
A typical thing you
might do with NSDate is
00:04:54.076 --> 00:04:58.886 A:middle
to get the current date, a date
object that represents now,
00:04:59.216 --> 00:05:02.266 A:middle
this very moment when I
making the method call.
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:04:59.216 --> 00:05:02.266 A:middle
this very moment when I
making the method call.
00:05:02.756 --> 00:05:04.966 A:middle
And I'll be using this
a bunch in the talk
00:05:04.966 --> 00:05:07.296 A:middle
so that's why I'm putting
it up in the slide now.
00:05:08.086 --> 00:05:11.336 A:middle
To get the current time or
a date with the current date
00:05:11.336 --> 00:05:14.156 A:middle
in it you simply call
the class method Date.
00:05:14.156 --> 00:05:17.146 A:middle
It's very simple,
straight forward.
00:05:18.236 --> 00:05:20.316 A:middle
So, because these
numbers are very large,
00:05:20.316 --> 00:05:22.266 A:middle
of course like numbers
of seconds,
00:05:22.266 --> 00:05:24.866 A:middle
they are really cumbersome
for human to deal with.
00:05:24.976 --> 00:05:30.336 A:middle
And so, we as humans over time
have developed these notions
00:05:30.336 --> 00:05:35.476 A:middle
of what we call in this case
dateComponents that is years
00:05:35.476 --> 00:05:38.856 A:middle
and months and days and hours
and minutes and seconds.
00:05:38.856 --> 00:05:43.016 A:middle
We break time down into either,
you know, something that relates
00:05:43.016 --> 00:05:46.786 A:middle
to an astronomical cycle, or
something artificial like hours
00:05:46.786 --> 00:05:51.986 A:middle
and minutes and seconds which
are easier for us to deal with.
00:05:52.256 --> 00:05:57.136 A:middle
Now, an NSDateComponents is a
slide says here a simple model
00:05:57.136 --> 00:05:59.756 A:middle
object with stores these
kinds of components.
00:05:59.806 --> 00:06:03.016 A:middle
So, if I have NSDateComponents
object I can set it
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:05:59.806 --> 00:06:03.016 A:middle
So, if I have NSDateComponents
object I can set it
00:06:03.016 --> 00:06:05.206 A:middle
as month property
to 6 for example
00:06:05.206 --> 00:06:06.796 A:middle
or it's day property to 14.
00:06:07.756 --> 00:06:09.296 A:middle
Now, the other properties like--
00:06:09.726 --> 00:06:12.076 A:middle
well there's many other
properties, other properties
00:06:12.076 --> 00:06:15.096 A:middle
like hours and minutes
and seconds, or year
00:06:15.266 --> 00:06:19.846 A:middle
or what the weekday is
or those kinds of things.
00:06:20.126 --> 00:06:23.966 A:middle
I've not specified in this
date components object
00:06:24.446 --> 00:06:26.466 A:middle
of what happens with those.
00:06:26.916 --> 00:06:30.826 A:middle
Well, the default value for
every component is "unspecified"
00:06:31.376 --> 00:06:32.636 A:middle
with NSDateComponents.
00:06:32.636 --> 00:06:37.596 A:middle
So, unless a value has been set
it has this value, special value
00:06:37.996 --> 00:06:40.126 A:middle
which is basically
blank has not been set.
00:06:40.126 --> 00:06:44.586 A:middle
And there's a constant for that
NSDateComponentsUnspecified.
00:06:48.316 --> 00:06:49.896 A:middle
NSCalendars where most
00:06:49.896 --> 00:06:53.166 A:middle
of the calendar calculations
APIs occur.
00:06:54.016 --> 00:06:57.906 A:middle
NSCalendar is the object
that represents various kinds
00:06:57.906 --> 00:07:02.756 A:middle
of world calendars and knows
how to do calendar math on them.
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:06:57.906 --> 00:07:02.756 A:middle
of world calendars and knows
how to do calendar math on them.
00:07:03.166 --> 00:07:06.906 A:middle
It knows how to take an NSDate
for example and break it
00:07:06.906 --> 00:07:09.786 A:middle
down into the components like
what is the year, what month
00:07:09.786 --> 00:07:12.246 A:middle
and day within a given calendar.
00:07:12.246 --> 00:07:15.516 A:middle
And the-- you know, various
kinds of calendars include
00:07:15.516 --> 00:07:17.276 A:middle
for example the Gregorian
calendar.
00:07:17.856 --> 00:07:20.376 A:middle
That's the calendar I'm mainly
going to be using in this talk
00:07:20.376 --> 00:07:22.236 A:middle
for some of my illustrations.
00:07:23.036 --> 00:07:27.426 A:middle
Here we see a calendar
showing January 2012.
00:07:28.556 --> 00:07:32.646 A:middle
But-- and the Gregorian
calendar is of course the--
00:07:32.646 --> 00:07:34.446 A:middle
a name for the what--
00:07:34.596 --> 00:07:36.936 A:middle
some people also call
the Western Calendar.
00:07:36.936 --> 00:07:41.146 A:middle
The calendar which is very
commonly used in commerce
00:07:41.146 --> 00:07:45.306 A:middle
for example around the world
even where a local calendar
00:07:45.306 --> 00:07:48.686 A:middle
like the Hebrew Calendar
or the Islamic Calendar,
00:07:49.036 --> 00:07:52.766 A:middle
or the Thai Buddhist
Calendar is being used instead
00:07:53.096 --> 00:07:56.096 A:middle
by the local people.
00:07:56.826 --> 00:08:01.336 A:middle
So, as I say, NSCalendar knows
how to convert between NSDates,
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:07:56.826 --> 00:08:01.336 A:middle
So, as I say, NSCalendar knows
how to convert between NSDates,
00:08:01.436 --> 00:08:05.936 A:middle
these very large numbers
which are not specific
00:08:05.936 --> 00:08:07.286 A:middle
to any particular calendar.
00:08:07.796 --> 00:08:10.726 A:middle
And the components that
is the human components
00:08:11.186 --> 00:08:15.326 A:middle
that humans are using with
the specific calendar systems.
00:08:16.716 --> 00:08:21.436 A:middle
NSCalendar also contains various
calendar calculation APIs.
00:08:21.436 --> 00:08:23.076 A:middle
And we'll be looking
at some of those today.
00:08:23.756 --> 00:08:26.206 A:middle
And it has several
properties as well
00:08:26.206 --> 00:08:28.336 A:middle
to control the calculation
parameters.
00:08:28.336 --> 00:08:32.566 A:middle
For example, what is the
time zone that I want
00:08:32.566 --> 00:08:34.515 A:middle
to do the calculations in.
00:08:35.515 --> 00:08:42.916 A:middle
To-- a common calendar that
when why use is the what we call
00:08:42.916 --> 00:08:44.336 A:middle
the autoupdatingCalendar.
00:08:44.936 --> 00:08:48.196 A:middle
And here I've shown a
very simple example of how
00:08:48.196 --> 00:08:49.166 A:middle
to create one of those.
00:08:50.176 --> 00:08:55.586 A:middle
The user on the system
hasn't preferred calendar.
00:08:55.586 --> 00:08:57.826 A:middle
There's a setting for that
or preference for that.
00:08:58.616 --> 00:09:01.496 A:middle
If the user changes
their preferred calendar,
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:08:58.616 --> 00:09:01.496 A:middle
If the user changes
their preferred calendar,
00:09:01.716 --> 00:09:03.886 A:middle
you may want your
application to update
00:09:04.116 --> 00:09:07.846 A:middle
to whatever the new
users preference is.
00:09:08.216 --> 00:09:12.196 A:middle
And so, this is-- what this does
is it returns a calendar object
00:09:12.546 --> 00:09:14.756 A:middle
which watches for changes
00:09:14.756 --> 00:09:18.596 A:middle
to the user's calendar
preference and updates itself.
00:09:18.646 --> 00:09:22.656 A:middle
So, you can use this and sort
of fire and forget if you will,
00:09:22.656 --> 00:09:27.156 A:middle
and not have to worry about
the user's calendar changing.
00:09:27.436 --> 00:09:29.136 A:middle
This thing will change itself
00:09:29.226 --> 00:09:32.426 A:middle
to match whatever the user's
setting is at any given point.
00:09:33.976 --> 00:09:37.996 A:middle
So, what are these calendar
calculations that you can do?
00:09:37.996 --> 00:09:39.826 A:middle
Well, there's many
different kinds of things
00:09:40.266 --> 00:09:41.746 A:middle
that why I'm want
to do but I'm going
00:09:41.746 --> 00:09:43.106 A:middle
to give a couple
of examples here.
00:09:43.426 --> 00:09:45.216 A:middle
So, here we are the
timeline again,
00:09:45.216 --> 00:09:48.736 A:middle
I've marked June
14th and August 26th.
00:09:49.356 --> 00:09:53.096 A:middle
And one might ask for example,
how many weeks are there
00:09:53.096 --> 00:09:54.886 A:middle
between these two dates?
00:09:55.486 --> 00:09:57.346 A:middle
Well, I know between-- strictly
00:09:57.346 --> 00:09:59.966 A:middle
between these two dates
there are 72 days.
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:10:00.526 --> 00:10:04.756 A:middle
And since there's seven days
in a week, that's 10 weeks,
00:10:04.806 --> 00:10:07.366 A:middle
they're up to 10 weeks
plus two extra days
00:10:07.826 --> 00:10:09.346 A:middle
in between these two dates.
00:10:10.646 --> 00:10:12.986 A:middle
Another kind of calculation
one might do is
00:10:12.986 --> 00:10:14.656 A:middle
to ask questions about weeks.
00:10:15.126 --> 00:10:16.586 A:middle
Now, here I'm going
to show a graphic
00:10:17.416 --> 00:10:22.486 A:middle
where I've highlighted
today, June 14th.
00:10:23.686 --> 00:10:26.966 A:middle
But one thing you might notice
is for example if you're used
00:10:26.966 --> 00:10:30.926 A:middle
to United States Convention
of starting the calendars
00:10:31.216 --> 00:10:33.016 A:middle
with Sunday on the far left,
00:10:33.016 --> 00:10:34.446 A:middle
you might noticed
this is little odd.
00:10:34.846 --> 00:10:36.386 A:middle
I've chosen to start
this calendar
00:10:36.386 --> 00:10:37.796 A:middle
with Monday is the first day.
00:10:38.306 --> 00:10:41.086 A:middle
And so, I've just doing
this to highlight the fact
00:10:41.086 --> 00:10:46.236 A:middle
that different kinds of locales
might choose different first
00:10:46.236 --> 00:10:48.946 A:middle
days in the week or different
days of the week to be the--
00:10:49.086 --> 00:10:50.306 A:middle
their first day of the week.
00:10:50.736 --> 00:10:53.756 A:middle
This is a convention that you
might see for example more often
00:10:53.756 --> 00:10:56.406 A:middle
in Europe than here
in the United States.
00:10:57.446 --> 00:11:01.466 A:middle
So, one question I
might to ask is given
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:10:57.446 --> 00:11:01.466 A:middle
So, one question I
might to ask is given
00:11:01.466 --> 00:11:03.306 A:middle
that today is the 14th of June.
00:11:03.956 --> 00:11:06.766 A:middle
What is the week that
contains this date?
00:11:07.386 --> 00:11:09.106 A:middle
Well, here I've highlighted it.
00:11:09.426 --> 00:11:11.436 A:middle
June 10th was the
first day of the week
00:11:11.676 --> 00:11:14.606 A:middle
in this particular
locale of this calendar.
00:11:15.706 --> 00:11:21.906 A:middle
And the week extends
through the 16th.
00:11:21.906 --> 00:11:25.046 A:middle
NSTimeZone then I
mentioned time zones already.
00:11:25.536 --> 00:11:27.056 A:middle
NSTimeZone is our object
00:11:27.056 --> 00:11:29.366 A:middle
that represents these
time zone regions.
00:11:29.766 --> 00:11:33.116 A:middle
A time zone is the
geo-political region
00:11:33.306 --> 00:11:35.846 A:middle
like the one I've
highlighted here with Geneva,
00:11:35.846 --> 00:11:38.376 A:middle
Switzerland having
the blue dot over it.
00:11:39.346 --> 00:11:41.376 A:middle
It's a geo-political
region of the world
00:11:41.846 --> 00:11:46.636 A:middle
that has a particular
offset from Universal Time
00:11:47.136 --> 00:11:49.946 A:middle
and a particular set
of rules that determine
00:11:49.946 --> 00:11:51.596 A:middle
when that offset changes.
00:11:52.376 --> 00:11:54.296 A:middle
Generally, we call that
kind of thing for example
00:11:54.296 --> 00:11:56.876 A:middle
"daylight saving time"
or "summer time."
00:11:57.916 --> 00:12:00.376 A:middle
And you see it's a very
irregular region but, you know,
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:11:57.916 --> 00:12:00.376 A:middle
And you see it's a very
irregular region but, you know,
00:12:00.786 --> 00:12:03.376 A:middle
I call it geo-political.
00:12:03.616 --> 00:12:06.586 A:middle
Geo meaning, you know,
related to the earth
00:12:06.786 --> 00:12:11.966 A:middle
and it is very much vertical
band of the earth which has more
00:12:11.966 --> 00:12:14.746 A:middle
or less the same
longitudes in it.
00:12:15.386 --> 00:12:19.286 A:middle
But also that word political
is important in geo-political
00:12:19.566 --> 00:12:24.596 A:middle
because each country within
a given longitude band could
00:12:24.866 --> 00:12:29.326 A:middle
of course decide on
its own that it has one
00:12:29.326 --> 00:12:32.466 A:middle
or another different set of
rules from other countries
00:12:32.906 --> 00:12:34.456 A:middle
within the same kind of band.
00:12:34.746 --> 00:12:37.406 A:middle
And it's NSTimeZone
that has to keep track
00:12:37.516 --> 00:12:40.796 A:middle
of all these different countries
rules about, for example,
00:12:41.086 --> 00:12:43.816 A:middle
when they go into daylight
saving time or summer time.
00:12:44.346 --> 00:12:46.776 A:middle
And when they come back
out-- back to standard time.
00:12:47.926 --> 00:12:52.376 A:middle
So, as I say NSTimeZone
is the object that knows
00:12:52.376 --> 00:12:55.656 A:middle
about the local offset
from Universal Time
00:12:55.956 --> 00:12:57.486 A:middle
and when that changes.
00:12:58.026 --> 00:13:00.246 A:middle
Now, very similar to NSCalendar,
WEBVTT
X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000
00:12:58.026 --> 00:13:00.246 A:middle
Now, very similar to NSCalendar,
00:13:01.486 --> 00:13:03.486 A:middle
you can create an
NSTimeZone object
00:13:03.806 --> 00:13:05.616 A:middle
which we call the
local time zone.
00:13:06.496 --> 00:13:10.466 A:middle
And this object will represent
whatever the current time zone
00:13:10.466 --> 00:13:13.516 A:middle
is that the user has set
on their computer system.
00:13:14.116 --> 00:13:16.096 A:middle
Or if the user has, you know,
00:13:16.096 --> 00:13:19.546 A:middle
requested that the time zone
changes the user moves around,
00:13:19.896 --> 00:13:22.256 A:middle
this object will
update itself based
00:13:22.256 --> 00:13:24.406 A:middle
on the user's location changes.
00:13:25.826 --> 00:13:29.376 A:middle
So, let's dive in now to
this Common Operations
00:13:29.496 --> 00:13:30.516 A:middle
that I want to talk about.
00:13:30.516 --> 00:13:33.746 A:middle
And I'm going to begin by
talking about midnight.
00:13:34.906 --> 00:13:38.046 A:middle
It's very common for
people to want to know
00:13:38.116 --> 00:13:40.816 A:middle
about midnight for
various reasons.
00:13:41.646 --> 00:13:44.566 A:middle
But midnight can be
a little problematic.
00:13:44.956 --> 00:13:46.916 A:middle