summaryrefslogtreecommitdiff
path: root/doc/html/date_time/local_time.html
blob: b348758e88741a54da3387c174c90e7f22a08715 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Local Time</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../date_time.html" title="Chapter&#160;12.&#160;Boost.Date_Time">
<link rel="prev" href="posix_time.html" title="Posix Time">
<link rel="next" href="date_time_io.html" title="Date Time Input/Output">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="posix_time.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="date_time_io.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="date_time.local_time"></a>Local Time</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="local_time.html#date_time.local_time.time_zone_base">Time Zone (abstract)</a></span></dt>
<dt><span class="section"><a href="local_time.html#date_time.local_time.posix_time_zone">Posix Time Zone</a></span></dt>
<dt><span class="section"><a href="local_time.html#date_time.local_time.tz_database">Time Zone Database</a></span></dt>
<dt><span class="section"><a href="local_time.html#date_time.local_time.custom_time_zone">Custom Time Zone</a></span></dt>
<dt><span class="section"><a href="local_time.html#date_time.local_time.local_date_time">Local Date Time</a></span></dt>
<dt><span class="section"><a href="local_time.html#date_time.local_time.local_time_period">Local Time Period</a></span></dt>
</dl></div>
<h3>
<a name="idp212078816"></a>Local Time System</h3>
<p>
    <a class="link" href="local_time.html#local_intro">Introduction</a> -- 
    <a class="link" href="local_time.html#local_ex">Usage Examples</a>
  </p>
<a name="local_intro"></a><h4>
<a name="idp212082480"></a>Introduction</h4>
<p>
    The library supports 4 main extensions for the management of local times. This includes 
    </p>
<table border="0" summary="Simple list" class="simplelist">
<tr><td>local_date_time -- locally adjusted time point</td></tr>
<tr><td>posix_time_zone -- time zone defined by posix string (eg: "EST10EDT,M10.5.0,M3.5.0/03")</td></tr>
<tr><td>time_zone_database -- get time zones by region from .csv file (eg: America/New York)</td></tr>
<tr><td>time_zone -- abstract time zone interface</td></tr>
</table>
<p>
  </p>
<p>
    Together, these extensions define a time system adjusted for recording times related to a specific earth location. This time system utilizes all the features and benefits of the posix_time system (see <a class="link" href="posix_time.html" title="Posix Time">posix_time</a> for full details). It uses a time_zone object which contains all the necessary data/rules to enable adjustments to and from various time zones. The time_zone objects used in date_time are handled via a boost::shared_ptr&lt;boost::local_time::time_zone&gt;.
  </p>
<p>
    The phrase "wall-clock" refers to the time that would be shown on a wall clock in a particular time zone at any point in time. Local_time uses a time zone object to account for differences in time zones and daylight savings adjustments. For example: While 5:00 pm, October 10, 2004 in Sydney Australia occurs at exactly the same instant as 3:00 am, October 10, 2004 in New York USA, it is a 14 hour difference in wall-clock times. However, a point in time just one day later will result in a 16 hour difference in wall-clock time due to daylight savings adjustments in both time zones. The local_time system tracks these by means of a time point, stored as UTC, and time_zone objects that contain all the necessary data to correctly calculate wall-clock times.
  </p>
<a name="local_ex"></a><h4>
<a name="idp212089904"></a>Usage Examples</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Example</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td><a class="link" href="examples.html#date_time.examples.simple_time_zone" title="Simple Time Zones">Simple Time Zone</a></td>
<td>Side by side examples of Time Zone usage. Both <span class="type">custom_time_zone</span> and <span class="type">posix_time_zone</span> are shown.</td>
</tr>
<tr>
<td><a class="link" href="examples.html#date_time.examples.calc_rules" title="Daylight Savings Calc Rules">Daylight Savings Calc Rules</a></td>
<td>Simple example showing the creation of all five <span class="type">dst_calc_rule</span> types.</td>
</tr>
<tr>
<td><a class="link" href="examples.html#date_time.examples.seconds_since_epoch" title="Seconds Since Epoch">Seconds Since Epoch</a></td>
<td>Example that calculates the total seconds elapsed since the epoch (1970-Jan-01) utilizing local_date_time.</td>
</tr>
</tbody>
</table></div>
<p>
  </p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.time_zone_base"></a>Time Zone (abstract)</h3></div></div></div>
<a class="link" href="local_time.html#time_zone_base_intro">Introduction</a> --
  <a class="link" href="local_time.html#time_zone_base_header">Header</a> --
  <a class="link" href="local_time.html#time_zone_base_constr">Construction</a> --
  <a class="link" href="local_time.html#time_zone_base_accessors">Accessors</a><a name="time_zone_base_intro"></a><h4>
<a name="idp212107488"></a>Introduction</h4>
<p>
    The time_zone_base class is an abstract base class template for representing time zones. Time zones are a set of data and rules that provide information about a time zone. The date_time library handles time_zones by means of a boost::shared_ptr&lt;time_zone_base&gt;. A user's custom time zone class will work in the date_time library by means of this shared_ptr.
  </p>
<p>
    For convienience, the time_zone_base class is typedef'd as time_zone. All references in the documentation to time_zone, are referring to this typedef.
  </p>
<a name="time_zone_base_header"></a><h4>
<a name="idp212110320"></a>Header</h4>
<p>
    The time_zone_base class is defined in the header:
    </p>
<pre class="programlisting">#include "boost/date_time/time_zone_base.hpp"
    </pre>
<p>
  </p>
<a name="time_zone_base_constr"></a><h4>
<a name="idp212112880"></a>Construction</h4>
<p>
    A default constructor is provided in the time_zone_base class. There are no private data members in this base class to initialize.
  </p>
<p>
    Template parameters are time_type (typically posix_time::ptime) and CharT (defaults to char).
  </p>
<a name="time_zone_base_accessors"></a><h4>
<a name="idp212115296"></a>Accessors</h4>
<p>
    All of the accessors listed here are pure virtual functions.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Syntax</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td valign="top"><pre class="screen">
string_type dst_zone_abbrev();</pre></td>
<td>Returns the daylight savings abbreviation for the represented time zone.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
string_type std_zone_abbrev();</pre></td>
<td>Returns the standard abbreviation for the represented time zone.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
string_type dst_zone_name();</pre></td>
<td>Returns the daylight savings name for the represented time zone.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
string_type std_zone_name();</pre></td>
<td>Returns the standard name for the represented time zone.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">bool has_dst();</pre></td>
<td>Returns true if this time zone does not make a daylight savings shift.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
time_type dst_local_start_time(year_type);</pre></td>
<td>The date and time daylight savings time begins in given year.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
time_type dst_local_end_time(year_type);</pre></td>
<td valign="top">The date and time daylight savings time ends in given year.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
time_duration_type base_utc_offset();</pre></td>
<td>The amount of time offset from UTC (typically in hours).</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
time_duration_type dst_offset();</pre></td>
<td>The amount of time shifted during daylight savings.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">
std::string to_posix_string();</pre></td>
<td>Returns a posix time zone string representation of this time_zone_base object. For a detailed description of a posix time zone string see <a class="link" href="local_time.html#date_time.local_time.posix_time_zone" title="Posix Time Zone">posix_time_zone</a>.</td>
</tr>
</tbody>
</table></div>
<p>
  </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.posix_time_zone"></a>Posix Time Zone</h3></div></div></div>
<a class="link" href="local_time.html#posix_time_zone_intro">Introduction</a> --
  <a class="link" href="local_time.html#posix_time_zone_notes">Important Notes</a> --
  <a class="link" href="local_time.html#posix_time_zone_header">Header</a> --
  <a class="link" href="local_time.html#posix_time_zone_constr">Construction</a> --
  <a class="link" href="local_time.html#posix_time_zone_accessors">Accessors</a><a name="posix_time_zone_intro"></a><h4>
<a name="idp212147632"></a>Introduction</h4>
<p>
    A posix_time_zone object is a set of data and rules that provide information about a time zone. Information such as the offset from UTC, it's name and abbreviation, as well as daylight savings rules, called <a class="link" href="local_time.html#date_time.local_time.dst_calc_rules">dst_calc_rules</a>. These rules are stored as a boost::shared_ptr&lt;dst_calc_rules&gt;.
  </p>
<p>
    As a convenience, a typedef for shared_ptr&lt;dst_calc_rules&gt; is provided.
    </p>
<pre class="programlisting">typedef boost::shared_ptr&lt;dst_calc_rules&gt; local_time::dst_calc_rule_ptr;</pre>
<p>
  </p>
<p>
    A posix_time_zone is unique in that the object is created from a Posix time zone string (IEEE Std 1003.1). A POSIX time zone string takes the form of:
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"std&#160;offset&#160;dst&#160;[offset],start[/time],end[/time]"&#160;(w/no&#160;spaces).</p></div>
<p>'std' specifies the abbrev of the time zone. 'offset' is the offset from UTC. 'dst' specifies the abbrev of the time zone during daylight savings time. The second offset is how many hours changed during DST. 'start' and 'end' are the dates when DST goes into (and out of) effect. 'offset' takes the form of:
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;[+|-]hh[:mm[:ss]]&#160;{h=0-23,&#160;m/s=0-59}</p></div>
<p>'time' and 'offset' take the same form. 'start' and 'end' can be one of three forms:
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;Mm.w.d&#160;{month=1-12,&#160;week=1-5&#160;(5&#160;is&#160;always&#160;last),&#160;day=0-6}<br>
&#160;&#160;&#160;&#160;&#160;&#160;Jn&#160;{n=1-365&#160;Feb29&#160;is&#160;never&#160;counted}<br>
&#160;&#160;&#160;&#160;&#160;&#160;n&#160;{n=0-365&#160;Feb29&#160;is&#160;counted&#160;in&#160;leap&#160;years}</p></div>
<p>
  </p>
<p>
    Exceptions will be thrown under the following conditions:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">An exception will be thrown for an invalid date spec (see <a class="link" href="gregorian.html#date_time.gregorian.date_class" title="Date">date class</a>).</li>
<li class="listitem">A boost::local_time::bad_offset exception will be thrown for:</li>
<li class="listitem">A DST start or end offset that is negative or more than 24 hours.</li>
<li class="listitem">A UTC zone that is greater than +14 or less than -12 hours.</li>
<li class="listitem">A boost::local_time::bad_adjustment exception will be thrown for a DST adjustment that is 24 hours or more (positive or negative)</li>
</ul></div>
<p>
  </p>
<p>As stated above, the 'offset' and '/time' portions of the string are not required. If they are not given they default to 01:00 for 'offset', and 02:00 for both occurrences of '/time'.
  </p>
<p>
    Some examples are:
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"<br>
&#160;&#160;&#160;&#160;&#160;&#160;"PST-8PDT,M4.1.0,M10.1.0"</p></div>
<p>These two are actually the same specification (defaults were used in the second string). This zone lies eight hours west of GMT and makes a one hour shift forward during daylight savings time. Daylight savings for this zone starts on the first Sunday of April at 2am, and ends on the first Sunday of October at 2am.
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"MST-7"</p></div>
<p>This zone is as simple as it gets. This zone lies seven hours west of GMT and has no daylight savings.
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"EST10EDT,M10.5.0,M3.5.0/03"</p></div>
<p>This string describes the time zone for Sydney Australia. It lies ten hours east of GMT and makes a one hour shift forward during daylight savings. Being located in the southern hemisphere, daylight savings begins on the last Sunday in October at 2am and ends on the last Sunday in March at 3am.
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"FST+3FDT02:00,J60/00,J304/02"</p></div>
<p>This specification describes a fictitious zone that lies three hours east of GMT. It makes a two hour shift forward for daylight savings which begins on March 1st at midnight, and ends on October 31st at 2am. The 'J' designation in the start/end specs signifies that counting starts at one and February 29th is never counted.
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"FST+3FDT,59,304"</p></div>
<p>This specification is significant because of the '59'. The lack of 'J' for the start and end dates, indicates that the Julian day-count begins at zero and ends at 365. If you do the math, you'll see that allows for a total of 366 days. This is fine in leap years, but in non-leap years '59' (Feb-29) does not exist. This will construct a valid posix_time_zone object but an exception will be thrown if the date of '59' is accessed in a non-leap year. Ex:
    </p>
<pre class="programlisting">posix_time_zone leap_day(std::string("FST+3FDT,59,304"));
leap_day.dst_local_start_time(2004); // ok
leap_day.dst_local_start_time(2003); // Exception thrown</pre>
<p>
  </p>
<p>
    The posix_time_zone objects are used via a boost::shared_ptr&lt;local_time::time_zone_base&gt;. As a convenience, a typedef for boost::shared_ptr&lt;local_time::time_zone_base&gt; is provided:
    </p>
<pre class="programlisting">typedef boost::shared_ptr&lt;time_zone_base&gt; local_time::time_zone_ptr;</pre>
<p>
  </p>
<p>
    See <a class="link" href="examples.html#date_time.examples.simple_time_zone" title="Simple Time Zones">Simple time zone</a> for a side by side example of time_zone and posix_time_zone usage.
  </p>
<a name="posix_time_zone_notes"></a><h4>
<a name="idp212171584"></a>Important Notes</h4>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">posix_time_zone objects use the standard and daylight savings abbreviations in place of the full names (see <a class="link" href="local_time.html#posix_time_zone_accessors">Accessors</a> below).</li>
<li class="listitem">'Jn' and 'n' date specifications can not be mixed in a specification string. Ex: "FST+3FDT,59,J304" </li>
<li class="listitem">'n' date specification of 59 represents Feb-29. Do not attempt to access in a non-leap year or an exception will be thrown.</li>
</ul></div>
<a name="posix_time_zone_header"></a><h4>
<a name="idp212175744"></a>Header</h4>
<p>
    The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
    </p>
<pre class="programlisting">#include "boost/date_time/local_time/local_time.hpp"</pre>
<p>
  </p>
<a name="posix_time_zone_constr"></a><h4>
<a name="idp212178288"></a>Construction</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Syntax</th>
<th>Example</th>
</tr></thead>
<tbody><tr>
<td valign="top"><pre class="screen">posix_time_zone(std::string)</pre></td>
<td>
<pre class="screen">std::string nyc("EST-5EDT,M4.1.0,M10.5.0");
time_zone_ptr zone(new posix_time_zone(nyc));</pre>
            </td>
</tr></tbody>
</table></div>
<p>
  </p>
<a name="posix_time_zone_accessors"></a><h4>
<a name="idp212185760"></a>Accessors</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_abbrev()</pre></td>
<td>Returns the daylight savings abbreviation for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_zone_abbrev(); // "EDT"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_abbrev()</pre></td>
<td>Returns the standard abbreviation for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;std_zone_abbrev(); // "EST"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_name()</pre></td>
<td>Returns the daylight savings ABBREVIATION for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_zone_name(); // "EDT"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_name()</pre></td>
<td>Returns the standard ABBREVIATION for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;std_zone_name(); // "EST"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool has_dst()</pre></td>
<td>Returns true when time_zone's shared_ptr to dst_calc_rules is not NULL.</td>
</tr>
<tr><td>
<pre class="screen">nyc_zone_sh_ptr-&gt;has_dst(); // true
phx_zone_sh_ptr-&gt;has_dst(); // false</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">
ptime dst_local_start_time(greg_year)</pre></td>
<td>The date and time daylight savings time begins in given year. Returns not_a_date_time if this zone has no daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_local_start_time(2004);
// 2004-Apr-04 02:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">
ptime dst_local_end_time(greg_year)</pre></td>
<td>The date and time daylight savings time ends in given year. Returns not_a_date_time if this zone has no daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_local_end_time(2004);
// 2004-Oct-31 02:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">
time_duration base_utc_offset()</pre></td>
<td>The amount of time offset from UTC (typically in hours).</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;base_utc_offset(); // -05:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">posix_time::time_duration dst_offset()</pre></td>
<td>The amount of time shifted during daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_offset(); // 01:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string to_posix_string()</pre></td>
<td>Returns a posix time zone string representation of this time_zone_base object. Depending on how the time_zone object was created, the date-spec format of the string will be in either 'M' notation or 'n' notation. Every possible date-spec that can be represented in 'J' notation can also be represented in 'n' notation. The reverse is not true so only 'n' notation is used for these types of date-specs. For a detailed description of a posix time zone string see <a class="link" href="local_time.html#date_time.local_time.posix_time_zone" title="Posix Time Zone">posix_time_zone</a>.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;to_posix_string();
// "EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"
phx_zone_sh_ptr-&gt;to_posix_string();
// "MST-07"
            </pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.tz_database"></a>Time Zone Database</h3></div></div></div>
<a class="link" href="local_time.html#tz_database_intro">Introduction</a> --
  <a class="link" href="local_time.html#tz_database_header">Header</a> --
  <a class="link" href="local_time.html#tz_database_constr">Construction</a> --
  <a class="link" href="local_time.html#tz_database_accessors">Accessors</a> --
  <a class="link" href="local_time.html#tz_database_datafile">Data File Details</a><a name="tz_database_intro"></a><h4>
<a name="idp212234704"></a>Introduction</h4>
<p>
    The local_time system depends on the ability to store time zone information. Our Time Zone Database (tz_database) is a means of permanently storing that data. The specifications for many time zones (377 at this time) are provided. These specifications are based on data found in the <a href="http://www.twinsun.com/tz/tz-link.htm" target="_top">zoneinfo datebase</a>. The specifications are stored in the file:</p>
<pre class="screen">libs/date_time/data/date_time_zonespec.csv</pre>
<p>. While this file already contains specifications for many time zones, it's real intent is for the user to modify it by adding (or removing) time zones to fit their application. See <a class="link" href="local_time.html#tz_database_datafile">Data File Details</a> to learn how this is accomplished.
  </p>
<a name="tz_database_header"></a><h4>
<a name="idp212239296"></a>Header</h4>
<p>
    The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
    </p>
<pre class="programlisting">#include "boost/date_time/local_time/local_time.hpp"
    </pre>
<p>
  </p>
<a name="tz_database_constr"></a><h4>
<a name="idp212241920"></a>Construction</h4>
<p>
    The only constructor takes no arguments and creates an empty database. It is up to the user to populate the database. This is typically achieved by loading the desired datafile, but can also be accomplished by means of the <code class="computeroutput">add_record(...)</code> function (see the <a class="link" href="local_time.html#tz_database_accessors">Accessors table</a>). A <code class="computeroutput">local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code class="computeroutput">local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">tz_database()</pre></td>
<td>Constructor creates an empty database.</td>
</tr>
<tr><td><pre class="screen">tz_database tz_db;</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool load_from_file(std::string)</pre></td>
<td>Parameter is path to a time zone spec csv file (see <a class="link" href="local_time.html#tz_database_datafile">Data File Details</a> for details on the contents of this file). This function populates the database with time zone records found in the zone spec file. A <code class="computeroutput">local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code class="computeroutput">local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.</td>
</tr>
<tr><td>
<pre class="screen">tz_database tz_db;
tz_db.load_from_file("./date_time_zonespec.csv");</pre>
            </td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="tz_database_accessors"></a><h4>
<a name="idp212260528"></a>Accessors</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool tz_db.add_record(std::string id, 
                      <a class="link" href="local_time.html#date_time.local_time.custom_time_zone_ptr">time_zone_ptr</a> tz);</pre></td>
<td>Adds a time_zone, or a posix_time_zone, to the database. ID is the region name for this zone (Ex: "America/Phoenix").</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr zone(
  new posix_time_zone("PST-8PDT,M4.1.0,M10.1.0")
);
std::string id("America/West_Coast");
tz_db.add_record(id, zone);</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_zone_ptr 
  tz_db.time_zone_from_region(string id);</pre></td>
<td>Returns a time_zone, via a time_zone_ptr, that matches the region listed in the data file. A null pointer is returned if no match is found.
            </td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr nyc =
  tz_db.time_zone_from_region("America/New_York");</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">vector&lt;string&gt; tz_db.region_list();</pre></td>
<td>Returns a vector of strings that holds all the region ID strings from the database.</td>
</tr>
<tr><td>
<pre class="screen">std::vector&lt;std::string&gt; regions;
regions = tz_db.region_list();</pre>
            </td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="tz_database_datafile"></a><h4>
<a name="idp212278880"></a>Data File Details</h4>
<a class="link" href="local_time.html#tz_database_fields">Field Description/Details</a><p>
    The csv file containing the zone_specs used by the boost::local_time::tz_database is intended to be customized by the library user. When customizing this file (or creating your own) the file must follow a specific format.
  </p>
<p>
    This first line is expected to contain column headings and is therefore
not processed by the tz_database.
  </p>
<p>
    Each record (line) must have eleven fields. Some of those fields can be empty. Every field (even empty ones) must be enclosed in double-quotes.
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;Ex:<br>
&#160;&#160;&#160;&#160;&#160;&#160;"America/Phoenix"&#160;&lt;-&#160;string&#160;enclosed&#160;in&#160;quotes<br>
&#160;&#160;&#160;&#160;&#160;&#160;""&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;-&#160;empty&#160;field<br>
&#160;&#160;&#160;&#160;</p></div>
<p>
  </p>
<p>
    Some fields represent a length of time. The format of these fields must be:
    </p>
<div class="literallayout"><p><br>
&#160;&#160;&#160;&#160;&#160;&#160;"{+|-}hh:mm[:ss]"&#160;&lt;-&#160;length-of-time&#160;format<br>
&#160;&#160;&#160;&#160;</p></div>
<p>
    Where the plus or minus is mandatory and the seconds are optional.
  </p>
<p>
    Since some time zones do not use daylight savings it is not always necessary for every field in a zone_spec to contain a value. All zone_specs must have at least ID and GMT offset. Zones that use daylight savings must have all fields filled except: STD ABBR, STD NAME, DST NAME. You should take note that DST ABBR is mandatory for zones that use daylight savings (see field descriptions for further details).
  </p>
<a name="tz_database_fields"></a><h4>
<a name="idp212286528"></a>Field Description/Details</h4>
<p>
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
        ID
        <p>
          Contains the identifying string for the zone_spec. Any string will do as long as it's unique. No two ID's can be the same.
        </p>
</li>
<li class="listitem">
        STD ABBR
      </li>
<li class="listitem">
        STD NAME
      </li>
<li class="listitem">
        DST ABBR
      </li>
<li class="listitem">
        DST NAME
        <p>
          These four are all the names and abbreviations used by the time zone being described. While any string will do in these fields, care should be taken. These fields hold the strings that will be used in the output of many of the local_time classes.
        </p>
</li>
<li class="listitem">
        GMT offset
        <p>
          This is the number of hours added to utc to get the local time before any daylight savings adjustments are made. Some examples are: America/New_York offset -5 hours, and Africa/Cairo offset +2 hours. The format must follow the length-of-time format described above.
        </p>
</li>
<li class="listitem">
        DST adjustment
        <p>
          The amount of time added to gmt_offset when daylight savings is in effect. The format must follow the length-of-time format described above.
        </p>
<p>
          NOTE: more rule capabilities are needed - this portion of the tz_database is incomplete
        </p>
</li>
<li class="listitem">
        DST Start Date rule
        <p>
          This is a specially formatted string that describes the day of year in which the transition take place. It holds three fields of it's own, separated by semicolons.
          </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
              The first field indicates the "nth" weekday of the month. The possible values are: 1 (first), 2 (second), 3 (third), 4 (fourth), 5 (fifth), and -1 (last).
            </li>
<li class="listitem">
              The second field indicates the day-of-week from 0-6 (Sun=0).
            </li>
<li class="listitem">
              The third field indicates the month from 1-12 (Jan=1).
            </li>
</ol></div>
<p>
          Examples are: "-1;5;9"="Last Friday of September", "2;1;3"="Second Monday of March"
        </p>
</li>
<li class="listitem">
        Start time
        <p>
          Start time is the number of hours past midnight, on the day of the start transition, the transition takes place. More simply put, the time of day the transition is made (in 24 hours format). The format must follow the length-of-time format described above with the exception that it must always be positive.
        </p>
</li>
<li class="listitem">
        DST End date rule
        <p>
          See DST Start date rule. The difference here is this is the day daylight savings ends (transition to STD).
        </p>
</li>
<li class="listitem">
        End time
        <p>
          Same as Start time.
        </p>
</li>
</ul></div>
<p>
  </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.custom_time_zone"></a>Custom Time Zone</h3></div></div></div>
<a class="link" href="local_time.html#custom_time_zone_intro">Introduction</a> --
  <a class="link" href="local_time.html#custom_time_zone_header">Header</a> --
  <a class="link" href="local_time.html#custom_time_zone_constr">Construction</a> --
  <a class="link" href="local_time.html#custom_time_zone_accessors">Accessors</a> --
  <a class="link" href="local_time.html#custom_time_zone_dependents">Dependent Types</a><a name="custom_time_zone_intro"></a><h4>
<a name="idp212307632"></a>Introduction</h4>
<p>
    A custom_time_zone object is a set of data and rules that provide information about a time zone. Information such as the offset from UTC, it's name and abbreviation, as well as daylight savings rules, called <a class="link" href="local_time.html#date_time.local_time.dst_calc_rules">dst_calc_rules</a>. These rules are handled via a boost::shared_ptr&lt;dst_calc_rules&gt;. Not all time zones utilize daylight savings, therefore, time_zone objects can be used with a NULL-assigned shared_ptr.
  </p>
<p>
    As a convenience, a typedef for shared_ptr&lt;dst_calc_rules&gt; is provided.
    </p>
<pre class="programlisting">typedef boost::shared_ptr&lt;dst_calc_rules&gt; local_time::dst_calc_rule_ptr;</pre>
<p>
  </p>
<a name="date_time.local_time.custom_time_zone_ptr"></a><p>
    The time_zone objects are used via a boost::shared_ptr&lt;local_time::time_zone&gt;. As a convenience, a typedef for boost::shared_ptr&lt;local_time::time_zone&gt; is provided: 
    </p>
<pre class="programlisting">typedef boost::shared_ptr&lt;time_zone&gt; local_time::time_zone_ptr;</pre>
<p>
  </p>
<a name="custom_time_zone_header"></a><h4>
<a name="idp212314528"></a>Header</h4>
<p>
    The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
    </p>
<pre class="programlisting">#include "boost/date_time/local_time/local_time.hpp"</pre>
<p>
  </p>
<a name="custom_time_zone_constr"></a><h4>
<a name="idp212317136"></a>Construction</h4>
<p>
    Construction of a custom_time_zone is dependent on four objects: a 
    <a class="link" href="posix_time.html#date_time.posix_time.time_duration" title="Time Duration">time_duration</a>, a <a class="link" href="local_time.html#time_zone_names">time_zone_names</a>, a <a class="link" href="local_time.html#dst_adjustment_offsets">dst_adjustment_offsets</a>, and a shared_ptr to a <a class="link" href="local_time.html#date_time.local_time.dst_calc_rules">dst_calc_rule</a>.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Syntax</th>
<th>Example</th>
</tr></thead>
<tbody><tr>
<td valign="top"><pre class="screen">custom_time_zone(...)
  Parameters:
    <a class="link" href="local_time.html#time_zone_names">names</a>, 
    <a class="link" href="posix_time.html#date_time.posix_time.time_duration" title="Time Duration">gmt_offset</a>, 
    <a class="link" href="local_time.html#dst_adjustment_offsets">dst_offsets</a>, 
    <a class="link" href="local_time.html#date_time.local_time.dst_calc_rules">dst_rules</a> </pre></td>
<td>See <a class="link" href="examples.html#date_time.examples.simple_time_zone" title="Simple Time Zones">simple_time_zone</a> example for time_zone usage</td>
</tr></tbody>
</table></div>
<p>
  </p>
<a name="custom_time_zone_accessors"></a><h4>
<a name="idp212332624"></a>Accessors</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_abbrev()</pre></td>
<td>Returns the daylight savings abbreviation for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_zone_abbrev();
// "EDT"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_abbrev()</pre></td>
<td>Returns the standard abbreviation for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;std_zone_abbrev();
// "EST"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_name()</pre></td>
<td>Returns the daylight savings name for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_zone_name(); 
// "Eastern Daylight Time"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_name()</pre></td>
<td>Returns the standard name for the represented time zone.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;std_zone_name();
// "Eastern Standard Time"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool has_dst()</pre></td>
<td>Returns true when custom_time_zone's shared_ptr to dst_calc_rules is not NULL.</td>
</tr>
<tr><td>
<pre class="screen">nyc_zone_sh_ptr-&gt;has_dst();
// true
phx_zone_sh_ptr-&gt;has_dst();
// false</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">dst_local_start_time(...)
  Return Type:
    ptime
  Parameter:
    greg_year</pre></td>
<td>The date and time daylight savings time begins in given year. Returns not_a_date_time if this zone has no daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_ptr-&gt;dst_local_start_time(2004);
// 2004-Apr-04 02:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">dst_local_end_time(...)
  Return Type:
    ptime
  Parameter:
    greg_year</pre></td>
<td>The date and time daylight savings time ends in given year. Returns not_a_date_time if this zone has no daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_ptr-&gt;dst_local_end_time(2004);
// 2004-Oct-31 02:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_duration base_utc_offset()</pre></td>
<td>The amount of time offset from UTC (typically in hours).</td>
</tr>
<tr><td><pre class="screen">nyc_ptr-&gt;base_utc_offset();
// -05:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_duration dst_offset()</pre></td>
<td>The amount of time shifted during daylight savings.</td>
</tr>
<tr><td><pre class="screen">nyc_zone_sh_ptr-&gt;dst_offset();
// 01:00</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string to_posix_string()</pre></td>
<td>Returns a posix time zone string representation of this time_zone object. Depending on how the time_zone object was created, the date-spec format of the string will be in either 'M' notation or 'n' notation. Every possible date-spec that can be represented in 'J' notation can also be represented in 'n' notation. The reverse is not true so only 'n' notation is used for these types of date-specs. For a detailed description of a posix time zone string see <a class="link" href="local_time.html#date_time.local_time.posix_time_zone" title="Posix Time Zone">posix_time_zone</a>.</td>
</tr>
<tr><td><pre class="screen">nyc_ptr-&gt;to_posix_string();
// "EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"
phx_ptr-&gt;to_posix_string();
// "MST-07"
            </pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="custom_time_zone_dependents"></a><h4>
<a name="idp212375248"></a>Dependent Types</h4>
<a class="link" href="local_time.html#time_zone_names">Time Zone Names</a> --
  <a class="link" href="local_time.html#dst_adjustment_offsets">Dst Adjustment Offsets</a> --
  <a class="link" href="local_time.html#date_time.local_time.dst_calc_rules">Daylight Savings Calc Rules</a><a name="time_zone_names"></a><h4>
<a name="idp212379120"></a>Time Zone Names</h4>
<p>
    The time_zone_names_base type is an immutable template class of four strings. One each for the name and abbreviation in standard time and daylight savings time. The time_zone_names type is a typedef of time_zone_names_base&lt;char&gt;.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_zone_names(...)
  Parameters:
    string std_name
    string std_abbrev
    string dst_name
    string dst_abbrev</pre></td>
<td>The only constructor, all four strings must be provided.</td>
</tr>
<tr><td>
<pre class="screen">string sn("Eastern Standard Time");
string sa("EST");
string dn("Eastern Daylight Time");
string da("EDT");
time_zone_names nyc_names(sn, sa, 
                          dn, da);</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_name()</pre></td>
<td>Returns the standard zone name</td>
</tr>
<tr><td><pre class="screen">nyc_names.std_zone_name();
// "Eastern Standard Time"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string std_zone_abbrev()</pre></td>
<td>Returns the standard zone abbreviation</td>
</tr>
<tr><td><pre class="screen">nyc_names.std_zone_abbrev();
// "EST"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_name()</pre></td>
<td>Returns the daylight savings zone name</td>
</tr>
<tr><td><pre class="screen">nyc_names.std_zone_name();
// "Eastern Daylight Time"</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">std::string dst_zone_abbrev()</pre></td>
<td>Returns the daylight savings zone abbreviation</td>
</tr>
<tr><td><pre class="screen">nyc_names.std_zone_abbrev();
// "EDT"</pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="dst_adjustment_offsets"></a><h4>
<a name="idp212403408"></a>Dst Adjustment Offsets</h4>
<p>
    The dst_adjustment_offsets type is a collection of three <a class="link" href="posix_time.html#date_time.posix_time.time_duration" title="Time Duration">time_duration</a> objects.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">dst_adjustment_offsets(...)
  Parameters:
    time_duration dst_adjust
    time_duration start_offset
    time_duration end_offset</pre></td>
<td>The first time_duration is the daylight savings adjustment. The second is the time which daylight savings starts on the start day. The third is the time daylight savings ends on the ending day.</td>
</tr>
<tr><td><pre class="screen">
dst_adjustment_offsets(hours(1), 
                       hours(2), 
                       hours(2));</pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="date_time.local_time.dst_calc_rules"></a><h4>
<a name="idp212414720"></a>Daylight Savings Calc Rules</h4>
<p>
    Daylight savings calc rules, named dst_calc_rules, are a series of objects that group appropriate <a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">date_generators</a> together to form rule sets. The individual rules objects are used via dst_calc_rule_ptr.
  </p>
<p>
    For a complete example of all five dst_calc_rule types, see: <a class="link" href="examples.html#date_time.examples.calc_rules" title="Daylight Savings Calc Rules">calc_rules example</a>.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Syntax</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td valign="top"><pre class="screen">partial_date_dst_rule(...)
  Parameters:
    start_rule
    end_rule</pre></td>
<td>Both the start and end rules are of type gregorian::partial_date.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">first_last_dst_rule(...)
  Parameters:
    start_rule
    end_rule</pre></td>
<td>The DST start rule is of type gregorian::first_day_of_the_week_in_month and the end rule is of type gregorian::last_day_of_the_week_in_month.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">last_last_dst_rule(...)
  Parameters:
    start_rule
    end_rule</pre></td>
<td>Both the start and end rules are of type gregorian::last_day_of_the_week_in_month.</td>
</tr>
<tr>
<td valign="top"><pre class="screen">nth_last_dst_rule(...)
  Parameters:
    start_rule
    end_rule</pre></td>
<td>The DST start rule is of type gregorian::nth_day_of_the_week_in_month and the end rule is of type gregorian::last_day_of_the_week_in_month.</td>
</tr>
<tr>
<td valign="top">
<pre class="screen">nth_kday_dst_rule(...)
  Parameters:
    start_rule
    end_rule)
(see note* below)</pre>
            </td>
<td>Both rules are of type gregorian::nth_day_of_the_week_in_month.</td>
</tr>
</tbody>
</table></div>
<p>
    </p>
<p>
      * Note: The name "nth_kday_dst_rule" is a bit cryptic. Therefore, a more descriptive name, "nth_day_of_the_week_in_month_dst_rule", is also provided.
    </p>
<p>
  </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.local_date_time"></a>Local Date Time</h3></div></div></div>
<a class="link" href="local_time.html#local_date_time_intro">Introduction</a> --
  <a class="link" href="local_time.html#local_date_time_header">Header</a> --
  <a class="link" href="local_time.html#local_date_time_clock_constr">Construct From Clock</a> --
  <a class="link" href="local_time.html#local_date_time_constr">Construction</a> --
  <a class="link" href="local_time.html#local_date_time_accessors">Accessors</a> --
  <a class="link" href="local_time.html#local_date_time_operators">Operators</a> --
  <a class="link" href="local_time.html#local_date_time_tm_func">Struct tm Functions</a><a name="local_date_time_intro"></a><h4>
<a name="idp212441504"></a>Introduction</h4>
<p>
    A local_date_time object is a point in time and an associated time zone. The time is represented internally as UTC.
  </p>
<a name="local_date_time_header"></a><h4>
<a name="idp212443344"></a>Header</h4>
<p>
    The inclusion of a single header will bring in all boost::local_time types,
functions, and IO operators.
    </p>
<pre class="programlisting">
      #include "boost/date_time/local_time/local_time.hpp"
    </pre>
<p>
  </p>
<a name="local_date_time_clock_constr"></a><h4>
<a name="idp212446016"></a>Construct From Clock</h4>
<p>
    Creation of a local_date_time object from clock is possible with either second, or sub second resolution.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>Syntax</th>
<th>Example</th>
</tr></thead>
<tbody>
<tr>
<td valign="top"><pre class="screen">local_microsec_clock(...)
  Return Type:
    local_date_time
  Parameter:
    time_zone_ptr</pre></td>
<td>
<pre class="screen">time_zone_ptr zone(
  new posix_time_zone("MST-07")
);
local_date_time ldt = 
  local_microsec_clock::local_time(
    zone);</pre>
            </td>
</tr>
<tr>
<td valign="top"><pre class="screen">local_sec_clock(...)
  Return Type:
    local_date_time 
  Parameter:
    time_zone_ptr</pre></td>
<td>
<pre class="screen">time_zone_ptr zone(
  new posix_time_zone("MST-07")
);
local_date_time ldt = 
  local_sec_clock::local_time(zone);</pre>
            </td>
</tr>
</tbody>
</table></div>
<p>
  </p>
<a name="local_date_time_constr"></a><h4>
<a name="idp212456672"></a>Construction</h4>
<p>
    Construction of a local_date_time object can be done with a ptime and a time_zone_ptr where the ptime represents UTC time. Construction with a wall-clock representation takes the form of a date, a time_duration, a time_zone_ptr, and a fourth parameter that addresses the following complication.
  </p>
<p>
    Construction from a wall-clock rep may result in differing shifts for a particular time zone, depending on daylight savings rules for that zone. This means it is also possible to create a local_date_time with a non-existent, or duplicated, UTC representation. These cases occur during the forward shift in time that is the transition into daylight savings and during the backward shift that is the transition out of daylight savings. The user has two options for handling these cases: a bool flag that states if the time is daylight savings, or an enum that states what to do when either of these cases are encountered.
  </p>
<p>
    The bool flag is ignored when the given time_zone has no daylight savings specification. When the daylight savings status of a given time label is calculated and it does not match the flag, a <code class="computeroutput">local_time::dst_not_valid</code> exception is thrown. If a time label is invalid (does not exist), a <code class="computeroutput">local_time::time_label_invalid</code> exception is thrown.
  </p>
<p>
    There are two elements in the <code class="computeroutput">local_date_time::DST_CALC_OPTIONS</code> enum: <code class="computeroutput">EXCEPTION_ON_ERROR</code> and <code class="computeroutput">NOT_DATE_TIME_ON_ERROR</code>. The possible exceptions thrown are a <code class="computeroutput">local_time::ambiguous_result</code> or a <code class="computeroutput">local_time::time_label_invalid</code>. The <code class="computeroutput">NOT_DATE_TIME_ON_ERROR</code> sets the time value to the special value <code class="computeroutput">local_time::not_a_date_time</code> in the event of either a invalid or an ambiguous time label.
  </p>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time(...)
  Parameters:
    posix_time::ptime
    time_zone_ptr</pre></td>
<td>The given time is expected to be UTC. Therefore, the given time will be adjusted according to the offset described in the time zone.</td>
</tr>
<tr><td>
<pre class="screen">
// 3am, 2004-Nov-05 local time
ptime pt(date(2004,Nov,5), 
         hours(10));
time_zone_ptr zone(
  new posix_time_zone("MST-07"));
local_date_time az(pt, zone);</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time(...)
  Parameters:
    date
    time_duration 
    time_zone_ptr
    bool</pre></td>
<td>The passed time information understood to be in the passed tz. The DST flag must be passed to indicate whether the time is in daylight savings or not. May throw a <code class="computeroutput">dst_not_valid</code> or <code class="computeroutput">time_label_invalid</code> exception.</td>
</tr>
<tr><td>
<pre class="screen">date d(2004,Nov,5);
time_duration td(5,0,0,0);
string z("PST-8PDT,M4.1.0,M10.1.0")
time_zone_ptr zone(
  new posix_time_zone(z));
local_date_time nyc(d, td, 
                    zone, false);</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time(...)
  Parameters:
    date
    time_duration
    time_zone_ptr
    DST_CALC_OPTIONS</pre></td>
<td>The passed time information understood to be in the passed tz. The DST flag is calculated according to the specified rule. May throw a <code class="computeroutput">ambiguous_result</code> or <code class="computeroutput">time_label_invalid</code> exception.</td>
</tr>
<tr><td>
<pre class="screen">date d(2004,Nov,5);
time_duration td(5,0,0,0);
string z("PST-8PDT,M4.1.0,M10.1.0")
time_zone_ptr zone(
  new posix_time_zone(z));
local_date_time nyc(d, td, zone, 
  NOT_DATE_TIME_ON_ERROR);</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time(local_date_time);</pre></td>
<td>Copy Constructor.</td>
</tr>
<tr><td><pre class="screen">local_date_time az_2(az);</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time(...)
  Parameters:
    special_values
    time_zone_ptr</pre></td>
<td>Special Values constructor.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr zone(
  new posix_time_zone("MST-07")
);
local_date_time nadt(not_a_date_time, 
                     zone);
// default NULL time_zone_ptr
local_date_time nadt(pos_infin);</pre>
            </td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="local_date_time_accessors"></a><h4>
<a name="idp212493472"></a>Accessors</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_zone_ptr zone()</pre></td>
<td>Returns associated time_zone object via a time_zone_ptr</td>
</tr>
<tr><td><pre class="screen"></pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_dst()</pre></td>
<td>Determines if time value is in DST for associated zone.</td>
</tr>
<tr><td>&#160;</td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">ptime utc_time()</pre></td>
<td>Converts the local time value to a UTC value.</td>
</tr>
<tr><td>
<pre class="screen">ptime pt(date(2004,Nov,5), 
         hours(10));
time_zone_ptr zone(
  new posix_time_zone("MST-07"));
local_date_time az(pt, zone);
az.utc_time(); // 10am 2004-Nov-5</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">ptime local_time()</pre></td>
<td>Returns the local time for this object (Wall-clock).</td>
</tr>
<tr><td><pre class="screen">ptime pt(date(2004,Nov,5), 
         hours(10));
time_zone_ptr zone(
  new posix_time_zone("MST-07"));
local_date_time az(pt, zone);
az.utc_time(); // 10am 2004-Nov-5
az.local_time(); // 3am 2004-Nov-5</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_in(...)
  Return Type:
    local_date_time 
  Parameters:
    time_zone_ptr
    time_duration</pre></td>
<td>Returns a local_date_time representing the same UTC time as calling object, plus optional time_duration, with given time zone.</td>
</tr>
<tr><td>
<pre class="screen">local_date_time nyc = az.local_time_in(nyc_zone);
// nyc == 7am 2004-Nov-5</pre>
            </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_infinity() const</pre></td>
<td>Returns true if local_date_time is either positive or negative infinity</td>
</tr>
<tr><td><pre class="screen">local_date_time ldt(pos_infin); 
ldt.is_infinity(); // --&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_neg_infinity() const</pre></td>
<td>Returns true if local_date_time is negative infinity</td>
</tr>
<tr><td><pre class="screen">local_date_time ldt(neg_infin);
ldt.is_neg_infinity(); // --&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_pos_infinity() const</pre></td>
<td>Returns true if local_date_time is positive infinity</td>
</tr>
<tr><td><pre class="screen">local_date_time ldt(neg_infin); 
ldt.is_pos_infinity(); // --&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_not_a_date_time() const</pre></td>
<td>Returns true if value is not a date</td>
</tr>
<tr><td><pre class="screen">local_date_time ldt(not_a_date_time);
ldt.is_not_a_date_time(); // --&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_special() const</pre></td>
<td>Returns true if local_date_time is any <code class="computeroutput">special_value</code>
</td>
</tr>
<tr><td><pre class="screen">local_date_time ldt(pos_infin); 
local_date_time ldt2(not_a_date_time);
time_zone_ptr 
  mst(new posix_time_zone("MST-07"));
local_date_time 
  ldt3(local_sec_clock::local_time(mst));
ldt.is_special(); // --&gt; true
ldt2.is_special(); // --&gt; true
ldt3.is_special(); // --&gt; false</pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="local_date_time_operators"></a><h4>
<a name="idp212534624"></a>Operators</h4>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator&lt;&lt;</pre></td>
<td>Output streaming operator. This operator is part of the v1.33 IO addition to date_time. For complete details on this feature see <a class="link" href="date_time_io.html" title="Date Time Input/Output">Date Time IO</a>. The default output is shown in this example.</td>
</tr>
<tr><td><pre class="screen">
time_zone_ptr zone(new posix_time_zone("MST-07");
local_date_time ldt(date(2005,Jul,4),
                    hours(20), 
                    false);
std::cout &lt;&lt; ldt &lt;&lt; std::endl;
// "2005-Jul-04 20:00:00 MST"
          </pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator&gt;&gt;</pre></td>
<td>Input streaming operator. This operator is part of the v1.33 IO addition to date_time. For complete details on this feature see <a class="link" href="date_time_io.html" title="Date Time Input/Output">Date Time IO</a>. At this time, <code class="computeroutput">local_date_time</code> objects can only be streamed in with a Posix Time Zone string. A complete description of a Posix Time Zone string can be found in the documentation for the <a class="link" href="local_time.html#posix_time_zone_intro">posix_time_zone</a> class.</td>
</tr>
<tr><td><pre class="screen">stringstream ss;
ss.str("2005-Jul-04 20:00:00 MST-07");
ss &gt;&gt; ldt;
          </pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator==, operator!=,
operator&gt;, operator&lt;,
operator&gt;=, operator&lt;=</pre></td>
<td>A full complement of comparison operators</td>
</tr>
<tr><td><pre class="screen">ldt1 == ldt2, etc</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator+, operator+=,
operator-, operator-=</pre></td>
<td>Addition, subtraction, and shortcut operators for <code class="computeroutput">local_date_time</code> and date duration types. These include: <code class="computeroutput">days</code>, <code class="computeroutput">months</code>, and <code class="computeroutput">years</code>.</td>
</tr>
<tr><td><pre class="screen">ldt + days(5), etc</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator+, operator+=,
operator-, operator-=</pre></td>
<td>Addition, subtraction, and shortcut operators for <code class="computeroutput">local_date_time</code> and <code class="computeroutput">time_duration</code>.</td>
</tr>
<tr><td><pre class="screen">ldt + hours(5), etc</pre></td></tr>
</tbody>
</table></div>
<a name="local_date_time_tm_func"></a><h4>
<a name="idp212565552"></a>Struct tm Functions</h4>
<p>Function for converting a <code class="computeroutput">local_date_time</code> object to a <code class="computeroutput">tm</code> struct is provided.</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">tm to_tm(local_date_time)</pre></td>
<td>A function for converting a <code class="computeroutput">local_date_time</code> object to a <code class="computeroutput">tm</code> struct.</td>
</tr>
<tr><td>
<pre class="screen">
// 6am, 2005-Jul-05 local time
std::string z("EST-05EDT,M4.1.0,M10.1.0");
ptime pt(date(2005,Jul,5), 
         hours(10));
time_zone_ptr zone( new posix_time_zone(z));
local_date_time ldt(pt, zone);
tm ldt_tm = to_tm(ldt);
/* tm_year =&gt; 105
   tm_mon  =&gt; 6
   tm_mday =&gt; 5
   tm_wday =&gt; 2 (Tuesday)
   tm_yday =&gt; 185
   tm_hour =&gt; 6
   tm_min  =&gt; 0
   tm_sec  =&gt; 0
   tm_isddst =&gt; 1 */</pre>
	  </td></tr>
</tbody>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="date_time.local_time.local_time_period"></a>Local Time Period</h3></div></div></div>
<a class="link" href="local_time.html#local_time_period_intro">Introduction</a> --
  <a class="link" href="local_time.html#local_time_period_header">Header</a> --
  <a class="link" href="local_time.html#local_time_period_constr">Construction</a> --
  <a class="link" href="local_time.html#local_time_period_accessors">Accessors</a> --
  <a class="link" href="local_time.html#local_time_period_operators">Operators</a><a name="local_time_period_intro"></a><h4>
<a name="idp212585104"></a>Introduction</h4>
<p>
    The class <code class="computeroutput">boost::local_time::local_time_period</code> provides direct representation for ranges between two local times. Periods provide the ability to simplify some types of calculations by simplifying the conditional logic of the program. 
  </p>
<p>
    A period that is created with beginning and end points being equal, or with a duration of zero, is known as a zero length period. Zero length periods are considered invalid (it is perfectly legal to construct an invalid period). For these periods, the <code class="computeroutput">last</code> point will always be one unit less that the <code class="computeroutput">begin</code> point.
  </p>
<a name="local_time_period_header"></a><h4>
<a name="idp212589936"></a>Header</h4>
<p>
    </p>
<pre class="programlisting">#include "boost/date_time/local_time/local_time.hpp" //include all types plus i/o
or
#include "boost/date_time/local_time/local_time_types.hpp" //no i/o just types</pre>
<p>
  </p>
<a name="local_time_period_constr"></a><h4>
<a name="idp212592560"></a>Construction</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period(...)
  Parameters:
    local_date_time beginning
    local_date_time end</pre></td>
<td> Create a period as [begin, end). If end is &lt;= begin then the period will be defined as invalid.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  beg(ptime(date(2005,Jan,1),hours(0)), zone);
local_date_time 
  end(ptime(date(2005,Feb,1),hours(0)), zone);
// period for the entire month of Jan 2005
local_time_period ltp(beg, end);</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period(...)
  Parameters:
    local_date_time beginning
    time_duration length</pre></td>
<td>Create a period as [begin, begin+len) where end would be begin+len. If len is &lt;= zero then the period will be defined as invalid.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  beg(ptime(date(2005,Jan,1),hours(0)), zone);
// period for the whole day of 2005-Jan-01
local_time_period ltp(beg, hours(24));</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period(local_time_period rhs)</pre></td>
<td>Copy constructor</td>
</tr>
<tr><td><pre class="screen">local_time_period ltp1(ltp);</pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="local_time_period_accessors"></a><h4>
<a name="idp212610048"></a>Accessors</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time begin()</pre></td>
<td>Return first local_date_time of the period.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  ldt((ptime(date(2005,Jan,1)),hours(0)), zone);
local_time_period ltp(ldt, hours(2));
ltp.begin(); // =&gt; 2005-Jan-01 00:00:00</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time last()</pre></td>
<td>Return last local_date_time in the period</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  ldt((ptime(date(2005,Jan,1),hours(0))), zone);
local_time_period ltp(ldt, hours(2));
ltp.last(); // =&gt; 2005-Jan-01 01:59:59.999999999</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_date_time end()</pre></td>
<td>Return one past the last in period</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  ldt((ptime(date(2005,Jan,1),hours(0))), zone);
local_time_period ltp(ldt, hours(2));
ltp.end(); // =&gt; 2005-Jan-01 02:00:00</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">time_duration length()</pre></td>
<td>Return the length of the local_time period.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  ldt((ptime(date(2005,Jan,1),hours(0))), zone);
local_time_period ltp(ldt, hours(2));
ltp.length(); // =&gt; 02:00:00</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool is_null()</pre></td>
<td>True if period is not well formed. eg: end less than or equal to begin.</td>
</tr>
<tr><td>
<pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  beg((ptime(date(2005,Feb,1),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Jan,1),hours(0))), zone);
local_time_period ltp(beg, end);
ltp.is_null(); // =&gt; true</pre>
	    </td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool contains(local_date_time)</pre></td>
<td>True if local_date_time is within the period. Zero length periods cannot contain any points</td>
</tr>
<tr><td><pre class="screen">time_zone_ptr 
  zone(new posix_time_zone("MST-07"));
local_date_time 
  beg((ptime(date(2005,Jan,1),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Feb,1),hours(0))), zone);
local_time_period jan_mst(beg, end);

local_date_time 
ldt((ptime(date(2005,Jan,15),hours(12))), zone);
jan_mst.contains(ldt); // =&gt; true

local_time_period zero(beg, beg);
zero.contains(beg); // false</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool contains(local_time_period)</pre></td>
<td>True if period is within the period</td>
</tr>
<tr><td><pre class="screen">// using jan_mst period from previous example

local_date_time 
  beg((ptime(date(2005,Jan,7),hours(0))), zone);
local_time_period ltp(beg, hours(24));

jan_mst.contains(ltp); // =&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">bool intersects(local_time_period)</pre></td>
<td> True if periods overlap</td>
</tr>
<tr><td><pre class="screen">// using jan_mst period from previous example

local_date_time 
  beg((ptime(date(2005,Jan,7),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Feb,7),hours(0))), zone);
local_time_period ltp(beg, end);

jan_mst.intersects(ltp); // =&gt; true</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period intersection(local_time_period)</pre></td>
<td>Calculate the intersection of 2 periods. Null if no intersection.</td>
</tr>
<tr><td><pre class="screen">// using jan_mst period from previous example

local_date_time 
  beg((ptime(date(2005,Jan,7),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Feb,7),hours(0))), zone);
local_time_period ltp(beg, end);

local_time_period res(jan_mst.intersection(ltp));
// res =&gt; 2005-Jan-07 00:00:00 through
// 2005-Jan-31 23:59:59.999999999 (inclusive)</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period merge(local_time_period)</pre></td>
<td>Returns union of two periods. Null if no intersection.</td>
</tr>
<tr><td><pre class="screen">// using jan_mst period from previous example

local_date_time 
  beg((ptime(date(2005,Jan,7),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Feb,7),hours(0))), zone);
local_time_period ltp(beg, end);

local_time_period res(jan_mst.merge(ltp));
// res =&gt; 2005-Jan-07 00:00:00 through
// 2005-Feb-06 23:59:59.999999999 (inclusive)</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">local_time_period span(local_time_period)</pre></td>
<td>Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).</td>
</tr>
<tr><td><pre class="screen">// using jan_mst period from previous example

local_date_time 
  beg((ptime(date(2005,Mar,1),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Apr,1),hours(0))), zone);
local_time_period mar_mst(beg, end);

local_time_period res(jan_mst.span(mar_mst));
// res =&gt; 2005-Jan-01 00:00:00 through
// 2005-Mar-31 23:59:59.999999999 (inclusive)</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">void shift(time_duration)</pre></td>
<td>Add duration to both begin and end.</td>
</tr>
<tr><td><pre class="screen">local_date_time 
  beg((ptime(date(2005,Mar,1),hours(0))), zone);
local_date_time 
  end((ptime(date(2005,Apr,1),hours(0))), zone);
local_time_period mar_mst(beg, end);

mar_mst.shift(hours(48));
// mar_mst =&gt; 2005-Mar-03 00:00:00 through
// 2005-Apr-02 23:59:59.999999999 (inclusive)</pre></td></tr>
</tbody>
</table></div>
<p>
  </p>
<a name="local_time_period_operators"></a><h4>
<a name="idp212662384"></a>Operators</h4>
<p>
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th rowspan="2" valign="top">Syntax</th>
<th>Description</th>
</tr>
<tr><th>Example</th></tr>
</thead>
<tbody>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator==, operator!=</pre></td>
<td>Equality operators. Periods are equal if ltp1.begin == ltp2.begin &amp;&amp; ltp1.last == ltp2.last</td>
</tr>
<tr><td><pre class="screen">if (ltp1 == ltp2) {...</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator&lt;</pre></td>
<td>Ordering with no overlap. True if ltp1.end() less than ltp2.begin()</td>
</tr>
<tr><td><pre class="screen">if (ltp1 &lt; ltp2) {...</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator&gt;</pre></td>
<td>Ordering with no overlap. True if ltp1.begin() greater than ltp2.end()</td>
</tr>
<tr><td><pre class="screen">if (ltp1 &gt; ltp2) {... etc</pre></td></tr>
<tr>
<td rowspan="2" valign="top"><pre class="screen">operator&lt;=, operator&gt;=</pre></td>
<td>Defined in terms of the other operators.</td>
</tr>
<tr><td>&#160;</td></tr>
</tbody>
</table></div>
<p>
  </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="posix_time.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="date_time_io.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>