File: iso_week.html

package info (click to toggle)
howardhinnant-date 3.0.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,456 kB
  • sloc: cpp: 29,835; sh: 204; ansic: 23; makefile: 19
file content (2916 lines) | stat: -rw-r--r-- 77,444 bytes parent folder | download | duplicates (2)
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
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>iso_week</title>

	<meta name="color-scheme" content="light dark" />
	<style>
	li, p {text-align:justify}
	ins {color:#00A000}
	del {color:#A00000}
	code {white-space:pre;}
	@media (prefers-color-scheme: dark)
	{
		ins {color:#88FF88}
		del {color:#FF5555}
	}
	</style>
</head>
<body>

<address align=right>
<br/>
<br/>
<a href="mailto:howard.hinnant@gmail.com">Howard E. Hinnant</a><br/>
2017-10-16<br/>
</address>
<hr/>
<h1 align=center><code>iso_week</code></h1>

<h2>Contents</h2>

<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Implementation">Implementation</a></li>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Reference">Reference</a></li>
</ul>

<a name="Introduction"></a><h2>Introduction</h2>

<p>
This paper fully documents an
<a href="https://en.wikipedia.org/wiki/ISO_week_date">ISO week date calendar</a>
that is fully interoperable with
<a href="date.html"><code>date</code></a>.
</p>

<a name="Implementation"></a><h2>Implementation</h2>

<p>
This entire library is implemented in a single header:
<a href="https://github.com/HowardHinnant/date/blob/master/include/date/iso_week.h">iso_week.h</a>
and is open source using the MIT license.
</p>

<a name="Overview"></a><h2>Overview</h2>

<p>
This library creates field types that hold the year, week number and weekday
associated with a <a href="https://en.wikipedia.org/wiki/ISO_week_date">ISO week date</a>.
For example, to specify the Saturday of the 51st week of 2015 one can say:
</p>

<blockquote><pre>
#include "iso_week.h"
#include &lt;iostream&gt;

int
main()
{
    using namespace iso_week::literals;
    auto iso_date = sat/51/2015;
    std::cout &lt;&lt; iso_date &lt;&lt; '\n';
}
</pre></blockquote>

<p>
The output of this program is:
</p>

<blockquote><pre>
2015-W51-Sat
</pre></blockquote>

<p>
In this example <code>iso_date</code> has type <code>iso_week::year_weeknum_weekday</code>,
and this type does nothing but hold the three quantities: <code>year</code>,
<code>weeknum</code> and <code>weekday</code>.  This is such trivial functionality that
it almost seems useless.  Anyone can write a type to be constructed from three values,
and then print them back out when requested.
</p>

<p>
The real power of <code>year_weeknum_weekday</code> is that it can implicitly convert to
and from <a href="date.html#sys_days"><code>sys_days</code></a>.  And
 <a href="date.html#sys_days"><code>sys_days</code></a> is just a type alias for:
</p>

<blockquote><pre>
std::chrono::time_point&lt;std::chrono::system_clock, days&gt;
</pre></blockquote>

<p>
This is the exact same <code>sys_days</code> used by the
<a href="date.html"><code>date</code></a> and <a href="tz.html">time zone</a>
libraries.  And so by simply having conversions to and from <code>sys_days</code>,
<code>iso_week::year_weeknum_weekday</code> becomes seamlessly interoperable with all
of the types in <a href="date.html"><code>date</code></a> and
<a href="tz.html">time zone</a> such as <code>date::year_month_day</code> and
<code>date::Zone</code>:
</p>

<blockquote><pre>
#include "date.h"
#include "iso_week.h"
#include "tz.h"
#include &lt;iostream&gt;

int
main()
{
    using namespace std::chrono;
    using namespace date;
    using namespace iso_week;
    auto zone = locate_zone("America/New_York");
    auto now = zone-&gt;to_local(system_clock::now());
    auto dp = floor&lt;days&gt;(now.first);
    auto iso_date = year_weeknum_weekday{dp};
    auto civil_date = year_month_day{dp};
    auto time = make_time(duration_cast&lt;minutes&gt;(now.first-dp));
    std::cout &lt;&lt; "It is currently " &lt;&lt; time &lt;&lt; ' ' &lt;&lt; now.second &lt;&lt; " on "
              &lt;&lt; iso_date &lt;&lt; " which is also " &lt;&lt; civil_date &lt;&lt; '\n';
}
</pre></blockquote>

<p>
Which just output for me:
</p>

<blockquote><pre>
It is currently 18:33 EST on 2015-W51-Sat which is also 2015-12-19
</pre></blockquote>

<p>
Or if you want to find the civil date of the last day of the ISO week year for 2015, then
(knowning the last day of the week is Sunday in this calendar) it is:
</p>

<blockquote><pre>
using namespace iso_week::literals;
std::cout &lt;&lt; date::year_month_day{2015_y/last/sun} &lt;&lt; '\n';
</pre></blockquote>

<p>
Which will output:
</p>

<blockquote><pre>
2016-01-03
</pre></blockquote>

<p>
And of course one can convert in the opposite direction:
</p>

<blockquote><pre>
using namespace date::literals;
std::cout &lt;&lt; iso_week::year_weeknum_weekday{2016_y/1/3} &lt;&lt; '\n';
</pre></blockquote>

<p>
Which will output:
</p>

<blockquote><pre>
2015-W53-Sun
</pre></blockquote>

<p>
In particular, note that for this day, the <code>iso_week::year</code> is 2015 and the
<code>date::year</code> is 2016.
</p>

<p>
This brings us to an important type-safety feature of these libraries:  The
<code>iso_week::year</code> and the <code>date::year</code> are two <i>distinct</i> types.
They represent concepts that are <i>very</i> similar.  They almost always have the same
value for the same <code>sys_days</code>.  But as in this example, they are occasionally
different.  It is not unheard of for computer systems to conflate these two very similar
types, resulting in bugs that are hard to find because they are relatively rare.  Having
the C++ type system help you keep these similar but different concepts distinct is a
solid step towards finding bugs at compile time!
</p>

<a name="Reference"></a><h2>Reference</h2>

<p>
Here is a detailed specification of the entire library.  This specification is detailed
enough that you could write your own implementation from it if desired.  But feel free
to use <a href="https://github.com/HowardHinnant/date/blob/master/include/date/iso_week.h">this one</a>
instead.  Each type, and each operation is simple
and predictable.
</p>

<table>
<tr><td>durations</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><a href="#days"><code>days</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#weeks"><code>weeks</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#years"><code>years</code></a></td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>time_point</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><a href="#sys_days"><code>sys_days</code></a></td></tr>

<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>types</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><a href="#last_week"><code>last_week</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#weekday"><code>weekday</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#weeknum"><code>weeknum</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#year"><code>year</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#year_weeknum"><code>year_weeknum</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#year_lastweek"><code>year_lastweek</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#weeknum_weekday"><code>weeknum_weekday</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#lastweek_weekday"><code>lastweek_weekday</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#year_weeknum_weekday"><code>year_weeknum_weekday</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#year_lastweek_weekday"><code>year_lastweek_weekday</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>date composition operators</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><a href="#_1"><code>constexpr year_weeknum operator/(const year&amp; y, const weeknum& wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_2"><code>constexpr year_weeknum operator/(const year&amp; y, int            wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_3"><code>constexpr year_lastweek operator/(const year&amp; y, last_week      wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_4"><code>constexpr weeknum_weekday operator/(const weeknum&amp; wn, const weekday&amp; wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_5"><code>constexpr weeknum_weekday operator/(const weeknum&amp; wn, int            wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_6"><code>constexpr weeknum_weekday operator/(const weekday&amp; wd, const weeknum&amp; wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_7"><code>constexpr weeknum_weekday operator/(const weekday&amp; wd, int            wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_8"><code>constexpr lastweek_weekday operator/(const last_week&amp; wn, const weekday&amp; wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_9"><code>constexpr lastweek_weekday operator/(const last_week&amp; wn, int            wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_10"><code>constexpr lastweek_weekday operator/(const weekday&amp; wd, const last_week&amp; wn) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_11"><code>constexpr year_weeknum_weekday operator/(const year_weeknum&amp; ywn, const weekday&amp; wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_12"><code>constexpr year_weeknum_weekday operator/(const year_weeknum&amp; ywn, int            wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_13"><code>constexpr year_weeknum_weekday operator/(const weeknum_weekday&amp; wnwd, const year&amp; y) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_14"><code>constexpr year_weeknum_weekday operator/(const weeknum_weekday&amp; wnwd, int         y) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_15"><code>constexpr year_lastweek_weekday operator/(const year_lastweek&amp; ylw, const weekday&amp; wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_16"><code>constexpr year_lastweek_weekday operator/(const year_lastweek&amp; ylw, int            wd) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr><td>&nbsp;</td><td><a href="#_17"><code>constexpr year_lastweek_weekday operator/(const lastweek_weekday&amp; lwwd, const year&amp; y) noexcept;</code></a></td></tr>
<tr><td>&nbsp;</td><td><a href="#_18"><code>constexpr year_lastweek_weekday operator/(const lastweek_weekday&amp; lwwd, int         y) noexcept;</code></a></td></tr>
</table>

<p>
Everything here is contained in the namespace <code>iso_week</code>. The literal
operators, and the constexpr field literals (e.g. <code>sun</code>, <code>last</code>,
etc.) are in namespace <code>iso_week::literals</code> and imported into namespace
<code>iso_week</code>.
</p>

<a name="days"></a><h3><code>days</code></h3>

<blockquote>
<p>
<code>days</code> is a <code>std::chrono::duration</code> with a tick period of 24 hours.
This definition is not an SI unit but <a
href="http://www.bipm.org/en/publications/si-brochure/table6.html">is accepted for use
with SI</a>.  <code>days</code> is the resultant type when subtracting two
<code>sys_days</code>s.
</p>
<pre>
using days = std::chrono::duration
    &lt;int, std::ratio_multiply&lt;std::ratio&lt;24&gt;, std::chrono::hours::period&gt;&gt;;
</pre></blockquote>

<a name="weeks"></a><h3><code>weeks</code></h3>

<blockquote>
<p>
<code>weeks</code> is a <code>std::chrono::duration</code> with a tick period of 7 days.
This definition is widely recognized and predates the Gregorian calendar.  It is
consistent with <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>.
<code>weeks</code> will implicitly convert to <code>days</code> but not vice-versa.
</p>
<pre>
using weeks = std::chrono::duration
    &lt;int, std::ratio_multiply&lt;std::ratio&lt;7&gt;, days::period&gt;&gt;;
</pre></blockquote>

<a name="years"></a><h3><code>years</code></h3>

<blockquote>
<p>
<code>years</code> is a <code>std::chrono::duration</code> with a tick period of 365.2425
days.  This definition accurately describes the length of the average year in the
ISO week calendar.  <code>years</code> is the resultant type when subtracting two
<code>year</code> field-based time points.  <code>years</code> is not implicitly
convertible to <code>days</code> or <code>weeks</code> nor vice-versa.
</p>
<pre>
using years = std::chrono::duration
    &lt;int, std::ratio_multiply&lt;std::ratio&lt;146097, 400&gt;, days::period&gt;&gt;;
</pre></blockquote>

<a name="sys_days"></a><h3><code>sys_days</code></h3>

<blockquote>
<p>
<code>sys_days</code> is a <code>std::chrono::time_point</code> using
<code>std::chrono::system_clock</code> and <code>days</code>.  This makes
<code>sys_days</code> interoperable with
<code>std::chrono::system_clock::time_point</code>.  It is simply a count of days since
the epoch of <code>std::chrono::system_clock</code> which in every implementation is
Jan. 1, 1970.  <code>sys_days</code> is a serial-based time point with a resolution of
<code>days</code>.
</p>
<pre>
using sys_days = std::chrono::time_point&lt;std::chrono::system_clock, days&gt;;
</pre>
</blockquote>

<a name="last_week"></a><h3><code>last_week</code></h3>

<blockquote>
<p>
<code>last_week</code> is a <code>struct</code> that is <code>CopyConstructible</code>.
There exists a <code>constexpr</code> instance of <code>last_week</code> named
<code>last</code>.  This is simply a tag type.  It is used to indicate the last week of
the year.
</p>

<pre>
struct last_week
{
    explicit last_week() = default;
};

inline namespace literals
{

constexpr iso_week::last_week last{};

}
</pre>

<p>
I am leading the C++ standard here a little with the <code>explicit</code> qualifier on
the default constructor.  This compiles today, but doesn't have quite the desired
semantics.  But it will when
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_toc.html#1518">CWG 1518</a>
passes.  This will make it so that <code>{}</code> won't implicitly convert to
<code>last_week</code>.  This addresses the concern expressed in
<a href="http://cplusplus.github.io/LWG/lwg-toc.html#2510">LWG 2510</a>.
</p>

</blockquote>

<a name="weekday"></a><h3><code>weekday</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class weekday
{
    unsigned char wd_;  // exposition only
public:
    explicit constexpr weekday(unsigned wd) noexcept;
    constexpr weekday(const sys_days&amp; dp) noexcept;
    constexpr weekday(date::weekday wd) noexcept;
    explicit weekday(int) = delete;

    weekday&amp; operator++() noexcept;
    weekday operator++(int) noexcept;
    weekday&amp; operator--() noexcept;
    weekday operator--(int) noexcept;

    weekday&amp; operator+=(const days&amp; d) noexcept;
    weekday&amp; operator-=(const days&amp; d) noexcept;

    constexpr explicit operator unsigned() const noexcept;
    constexpr operator date::weekday() const noexcept;
    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const weekday&amp; x, const weekday&amp; y) noexcept;
constexpr bool operator!=(const weekday&amp; x, const weekday&amp; y) noexcept;

constexpr weekday operator+(const weekday&amp; x, const days&amp;    y) noexcept;
constexpr weekday operator+(const days&amp;    x, const weekday&amp; y) noexcept;
constexpr weekday operator-(const weekday&amp; x, const days&amp;    y) noexcept;
constexpr days    operator-(const weekday&amp; x, const weekday&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weekday&amp; wd);

inline namespace literals
{
constexpr weekday mon{1u};
constexpr weekday tue{2u};
constexpr weekday wed{3u};
constexpr weekday thu{4u};
constexpr weekday fri{5u};
constexpr weekday sat{6u};
constexpr weekday sun{7u};
}  // namespace literals
</pre>

<p><b>Overview</b></p>

<p>
<code>weekday</code> represents a day of the week in the ISO week calendar.  It should
only be representing values in the range 1 to 7, corresponding to Monday thru Sunday. 
However it may hold values outside this range.  It can be constructed with any
<code>unsigned</code> value, which will be subsequently truncated to fit into
<code>weekday</code>'s internal storage.  <code>weekday</code> is equality comparable.
<code>weekday</code> is not less-than comparable because there is no universal consensus
on which day is the first day of the week.  This design chooses the encoding of 1 to 7 to
represent Monday thru Sunday only because this is consistent with ISO 8601.
 However  <code>weekday</code>'s comparison and arithmetic operations treat the
days of the week as a circular range, with no beginning and no end.   One can stream out a
<code>weekday</code> for debugging purposes. <code>weekday</code> has explicit conversions
to and from <code>unsigned</code>.  There are 7 <code>weekday</code> constants, one for each
day of the week.
</p>

<p>
A <code>weekday</code> can be implicitly constructed from a <code>sys_days</code>. This
is the computation that discovers the day of the week of an arbitrary date.
</p>

<p>
A <code>weekday</code> can be implicitly converted to or from a <code>date::weekday</code>.
<code>iso_week::weekday</code> and <code>date::weekday</code> are distinct types, though
they represent very similar concepts.  <code>date::weekday</code> can be indexed, and
<code>iso_week::weekday</code> can not.  <code>date::weekday</code> is encoded as
[0, 6] representing [Sunday, Saturday], while <code>iso_week::weekday</code> is encoded as
[1, 7] representing [Monday, Sunday].  The conversion functions will correctly translate
between these encodings.
</p>

<p><b>Specification</b></p>

<p>
<code>weekday</code> is a trivially copyable class type.</br>
<code>weekday</code> is a standard-layout class type.</br>
<code>weekday</code> is a literal class type.</br>
</p>

<pre>
explicit constexpr weekday::weekday(unsigned wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weekday</code> by constructing
<code>wd_</code> with <code>wd</code>.
</p>
</blockquote>

<pre>
constexpr weekday(const sys_days&amp; dp) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weekday</code> by computing what day
of the week corresponds to the <code>sys_days dp</code>, and representing that day of
the week in <code>wd_</code>.
</p>
<p>
<i>Example:</i> If <code>dp</code> represents 1970-01-01, the constructed
<code>weekday</code> shall represent Thursday by storing 4 in <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr weekday(date::weekday wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weekday</code> from a
<code>date::weekday</code>.  This changes the underlying encoding from [0, 6] -&gt;
[sun, sat] to [1, 7] -&gt; [mon, sun].
</p>
</blockquote>

<pre>
weekday&amp; weekday::operator++() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> If <code>wd_ != 6</code>, <code>++wd_</code>.  Otherwise sets
<code>wd_</code> to 0.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weekday weekday::operator++(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>++(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
weekday&amp; weekday::operator--() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> If <code>wd_ != 0</code>, <code>--wd_</code>.  Otherwise sets
<code>wd_</code> to 6.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weekday weekday::operator--(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>--(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
weekday&amp; weekday::operator+=(const days&amp; d) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this + d</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weekday&amp; weekday::operator-=(const days&amp; d) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this - d</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr explicit weekday::operator unsigned() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr operator date::weekday() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> An object of type <code>date::weekday</code> constructed from
<code>*this</code>.  This changes the underlying encoding from [1, 7] -&gt; [mon, sun] to
[0, 6] -&gt; [sun, sat].
</p>
</blockquote>

<pre>
constexpr bool weekday::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>1 &lt;= wd_ &amp;&amp; wd_ &lt;= 7</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const weekday&amp; x, const weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>unsigned{x} == unsigned{y}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const weekday&amp; x, const weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr weekday  operator+(const weekday&amp;  x, const days&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> A <code>weekday</code> for which <code>ok() == true</code> and is found as
if by incrementing (or decrementing if <code>y &lt; days{0}</code>) <code>x</code>,
<code>y</code> times.  If <code>weekday.ok() == false</code> prior to this operation,
behaves as if <code>*this</code> is first brought into the range [1, 7] by modular
arithmetic. [<i>Note:</i> For example <code>weekday{0}</code> becomes
<code>weekday{7}</code>. &mdash; <i>end note</i>]
</p>
<p>
<i>Complexity:</i> O(1) with respect to the value of <code>y</code>.  That is, repeated
increments or decrements is not a valid implementation.
</p>
<p>
<i>Example:</i> <code>sun + days{6} == sat</code>.
</p>
</blockquote>

<pre>
constexpr weekday  operator+(const days&amp; x, const weekday&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y + x</code>.
</p>
</blockquote>

<pre>
constexpr weekday  operator-(const weekday&amp;  x, const days&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + -y</code>.
</p>
</blockquote>

<pre>
constexpr days operator-(const weekday&amp;  x, const weekday&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Requires:</i> <code>x.ok() == true</code> and <code>y.ok() == true</code>.
</p>
<p>
<i>Returns:</i> A value of <code>days</code> in the range of <code>days{0}</code> to
<code>days{6}</code> inclusive.
</p>
<p>
<i>Remarks:</i> The returned value <code>d</code> shall satisfy the equality:
<code>y + d == x</code>.
</p>
<p>
<i>Example:</i> <code>sat - sun == days{6}</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weekday&amp; wd);
</pre>

<blockquote>
<p>
<i>Effects:</i>  If <code>ok() == true</code> outputs the same string that would be
output for the weekday field by <code>asctime</code>, assuming the conversion
<code>unsigned{date::weekday{*this}}</code>.  Otherwise outputs
<code>unsigned{wd} &lt;&lt; " is not a valid weekday"</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="weeknum"></a><h3><code>weeknum</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class weeknum
{
    unsigned char wn_;  // exposition only

public:
    explicit constexpr weeknum(unsigned wn) noexcept;

    weeknum&amp; operator++() noexcept;
    weeknum operator++(int) noexcept;
    weeknum&amp; operator--() noexcept;
    weeknum operator--(int) noexcept;

    weeknum&amp; operator+=(const weeks&amp; w) noexcept;
    weeknum&amp; operator-=(const weeks&amp; w) noexcept;

    constexpr explicit operator unsigned() const noexcept;
    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const weeknum&amp; x, const weeknum&amp; y) noexcept;
constexpr bool operator!=(const weeknum&amp; x, const weeknum&amp; y) noexcept;
constexpr bool operator&lt; (const weeknum&amp; x, const weeknum&amp; y) noexcept;
constexpr bool operator&gt; (const weeknum&amp; x, const weeknum&amp; y) noexcept;
constexpr bool operator&lt;=(const weeknum&amp; x, const weeknum&amp; y) noexcept;
constexpr bool operator&gt;=(const weeknum&amp; x, const weeknum&amp; y) noexcept;

constexpr weeknum operator+(const weeknum&amp; x, const weeks&amp;   y) noexcept;
constexpr weeknum operator+(const weeks&amp;   x, const weeknum&amp; y) noexcept;
constexpr weeknum operator-(const weeknum&amp; x, const weeks&amp;   y) noexcept;
constexpr weeks   operator-(const weeknum&amp; x, const weeknum&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weeknum&amp; wn);

inline namespace literals
{

constexpr weeknum operator "" _w(unsigned long long wn) noexcept;

}
</pre>

<p><b>Overview</b></p>

<p>
<code>weeknum</code> represents a week number of of the ISO week-year [1, 53]. It should
only be representing values in the range 1 to 53.  However it may hold values outside this
range.  It can be constructed with any <code>unsigned</code> value, which will be
subsequently truncated to fit into <code>weeknum</code>'s internal storage. 
<code>weeknum</code> is equality and less-than comparable, and participates in basic
arithmetic with <code>weeks</code> representing the quantity between any two
<code>weeknum</code>'s.   One can stream out a <code>weeknum</code> for debugging
purposes. <code>weeknum</code> has explicit conversions to and from <code>unsigned</code>.
</p>

<p><b>Specification</b></p>

<p>
<code>weeknum</code> is a trivially copyable class type.</br>
<code>weeknum</code> is a standard-layout class type.</br>
<code>weeknum</code> is a literal class type.</br>
</p>

<pre>
explicit constexpr weeknum::weeknum(unsigned wn) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weeknum</code> by constructing
<code>wn_</code> with <code>wn</code>.
</p>
</blockquote>

<pre>
weeknum&amp; weeknum::operator++() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>++wn_</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weeknum weeknum::operator++(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>++(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
weeknum&amp; weeknum::operator--() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>--wn_</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weeknum weeknum::operator--(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>--(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
weeknum&amp; weeknum::operator+=(const weeks&amp; w) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this + w</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
weeknum&amp; weeknum::operator-=(const weeks&amp; w) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this - w</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr explicit weeknum::operator unsigned() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wn_</code>.
</p>
</blockquote>

<pre>
constexpr bool weeknum::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>1 &lt;= wn_ && wn_ &lt;= 53</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>unsigned{x} == unsigned{y}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt; (const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>unsigned{x} &lt; unsigned{y}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt; (const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const weeknum&amp; x, const weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr weeknum  operator+(const weeknum&amp;  x, const weeks&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>weeknum{unsigned{x} + static_cast&lt;unsigned&gt;(y.count())}</code>
</p>
</blockquote>

<pre>
constexpr weeknum  operator+(const weeks&amp; x, const weeknum&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y + x</code>.
</p>
</blockquote>

<pre>
constexpr weeknum  operator-(const weeknum&amp;  x, const weeks&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + -y</code>.
</p>
</blockquote>

<pre>
constexpr weeks operator-(const weeknum&amp;  x, const weeknum&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>weeks{static_cast&lt;weeks::rep&gt;(unsigned{x}) -
              static_cast&lt;weeks::rep&gt;(unsigned{y})}</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weeknum&amp; wn);
</pre>

<blockquote>
<p>
<i>Effects:</i> Inserts 'W' followed by a decimal integral text representation of
length 2, prefixed by '0' if the value is less than or equal to 9.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
<p>
<i>Example:</i> <code>5_w</code> is output as <code>W05</code>.</i>
</p>
</blockquote>

<pre>
constexpr weeknum operator "" _w(unsigned long long wn) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>weeknum{static_cast&lt;unsigned&gt;(wn)}</code>.
</p>
</blockquote>

</blockquote>

<a name="year"></a><h3><code>year</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class year
{
    short y_;  // exposition only

public:
    explicit constexpr year(int y) noexcept;

    year&amp; operator++() noexcept;
    year operator++(int) noexcept;
    year&amp; operator--() noexcept;
    year operator--(int) noexcept;

    year&amp; operator+=(const years&amp; y) noexcept;
    year&amp; operator-=(const years&amp; y) noexcept;

    constexpr explicit operator int() const noexcept;
    constexpr bool ok() const noexcept;

    static constexpr year min() noexcept;
    static constexpr year max() noexcept;
};

constexpr bool operator==(const year&amp; x, const year&amp; y) noexcept;
constexpr bool operator!=(const year&amp; x, const year&amp; y) noexcept;
constexpr bool operator&lt; (const year&amp; x, const year&amp; y) noexcept;
constexpr bool operator&gt; (const year&amp; x, const year&amp; y) noexcept;
constexpr bool operator&lt;=(const year&amp; x, const year&amp; y) noexcept;
constexpr bool operator&gt;=(const year&amp; x, const year&amp; y) noexcept;

constexpr year  operator+(const year&amp;  x, const years&amp; y) noexcept;
constexpr year  operator+(const years&amp; x, const year&amp;  y) noexcept;
constexpr year  operator-(const year&amp;  x, const years&amp; y) noexcept;
constexpr years operator-(const year&amp;  x, const year&amp;  y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year&amp; y);

inline namespace literals
{
constexpr year operator "" _y(unsigned long long y) noexcept;
}
</pre>

<p><b>Overview</b></p>

<p>
<code>year</code> represents a year in the
<a href="https://en.wikipedia.org/wiki/ISO_week_date">ISO week date calendar</a>.
It shall represent values in the range <code>[min(), max()]</code>.  It can be constructed
with any <code>int</code> value, which will be subsequently truncated to fit into
<code>year</code>'s internal storage.  <code>year</code> is equality and less-than
comparable, and participates in basic arithmetic with <code>years</code> representing the
quantity between any two <code>year</code>'s.  One can form a <code>year</code> literal
with <code>_y</code>.  And one can stream out a <code>year</code> for debugging purposes.
<code>year</code> has explicit conversions to and from <code>int</code>.
</p>

<p><b>Specification</b></p>

<p>
<code>year</code> is a trivially copyable class type.</br>
<code>year</code> is a standard-layout class type.</br>
<code>year</code> is a literal class type.</br>
</p>

<pre>
explicit constexpr year::year(int y) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year</code> by constructing
<code>y_</code> with <code>y</code>.
</p>
</blockquote>

<pre>
year&amp; year::operator++() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>++y_</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year year::operator++(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>++(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
year&amp; year::operator--() noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>--y_</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year year::operator--(int) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>--(*this)</code>.
</p>
<p>
<i>Returns:</i> A copy of <code>*this</code> as it existed on entry to this member
function.
</p>
</blockquote>

<pre>
year&amp; year::operator+=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this + y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year&amp; year::operator-=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this - y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr explicit year::operator int() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_</code>.
</p>
</blockquote>

<pre>
constexpr bool year::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>min() &lt;= *this &amp;&amp; *this &lt;= max()</code>.
</p>
</blockquote>

<pre>
static constexpr year year::min() noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> A <code>year</code> constructed with the minimum representable year
number. This year shall be a value such that
<code>sys_days{min()/1_w/mon} + Unit{0}</code>, where <code>Unit</code> is one of
<code>microseconds</code>, <code>milliseconds</code>, <code>seconds</code>,
<code>minutes</code>, or <code>hours</code>, there shall be no overflow.  [<i>Note:</i>
<code>nanoseconds</code> is intentionally omitted from this list. &mdash; <i>end note</i>]
</p>
</blockquote>

<pre>
static constexpr year year::max() noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> A <code>year</code> constructed with the maximum representable year
number. This year shall be a value such that
<code>sys_days{max()/last/sun} + Unit{0}</code>, where <code>Unit</code> is one of
<code>microseconds</code>, <code>milliseconds</code>, <code>seconds</code>,
<code>minutes</code>, or <code>hours</code>, there shall be no overflow.  [<i>Note:</i>
<code>nanoseconds</code> is intentionally omitted from this list. &mdash; <i>end note</i>]
</p>
</blockquote>

<pre>
constexpr bool operator==(const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>int{x} == int{y}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt; (const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>int{x} &lt; int{y}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt; (const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const year&amp; x, const year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr year  operator+(const year&amp;  x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>year{int{x} + y.count()}</code>.
</p>
</blockquote>

<pre>
constexpr year  operator+(const years&amp; x, const year&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y + x</code>.
</p>
</blockquote>

<pre>
constexpr year  operator-(const year&amp;  x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + -y</code>.
</p>
</blockquote>

<pre>
constexpr years operator-(const year&amp;  x, const year&amp;  y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>years{int{x} - int{y}}</code>.
</p>
</blockquote>

<pre>
constexpr year operator "" _y(unsigned long long y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>year{static_cast&lt;int&gt;(y)}</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year&amp; y);
</pre>

<blockquote>
<p>
<i>Effects:</i> Inserts a signed decimal integral text representation of <code>y</code>
into <code>os</code>. If the year is less than four decimal digits, pads the year with
<code>'0'</code> to four digits.  If the year is negative, prefixes with <code>'-'</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

<pre>
constexpr year operator "" _y(unsigned long long y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>year{static_cast&lt;int&gt;(y)}</code>.
</p>
</blockquote>

</blockquote>

<a name="year_weeknum"></a><h3><code>year_weeknum</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class year_weeknum
{
    iso_week::year    y_;   // exposition only
    iso_week::weeknum wn_;  // exposition only

public:
    constexpr year_weeknum(const iso_week::year&amp; y, const iso_week::weeknum&amp; wn) noexcept;

    constexpr iso_week::year    year()    const noexcept;
    constexpr iso_week::weeknum weeknum() const noexcept;

    year_weeknum&amp; operator+=(const years&amp; dy) noexcept;
    year_weeknum&amp; operator-=(const years&amp; dy) noexcept;

    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
constexpr bool operator!=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
constexpr bool operator&lt; (const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
constexpr bool operator&gt; (const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
constexpr bool operator&lt;=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
constexpr bool operator&gt;=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;

constexpr year_weeknum operator+(const year_weeknum&amp; ym, const years&amp; dy) noexcept;
constexpr year_weeknum operator+(const years&amp; dy, const year_weeknum&amp; ym) noexcept;
constexpr year_weeknum operator-(const year_weeknum&amp; ym, const years&amp; dy) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_weeknum&amp; ym);
</pre>

<p><b>Overview</b></p>

<p>
<code>year_weeknum</code> is simply a collection of a <code>year</code> and a
<code>weeknum</code>.  It represents a specific week of a year, but not the day of the
week.  One can perform year-oriented arithmetic with a <code>year_weeknum</code>.  And
<code>year_weeknum</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>year_weeknum</code> is a trivially copyable class type.</br>
<code>year_weeknum</code> is a standard-layout class type.</br>
<code>year_weeknum</code> is a literal class type.</br>
</p>

<pre>
constexpr year_weeknum::year_weeknum(const iso_week::year&amp; y, const iso_week::weeknum&amp; wn) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_weeknum</code> by constructing
<code>y_</code> with <code>y</code> and <code>wn_</code> with <code>wn</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::year year_weeknum::year() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weeknum year_weeknum::weeknum() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wn_</code>.
</p>
</blockquote>

<pre>
year_weeknum&amp; year_weeknum::operator+=(const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this + dy</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year_weeknum&amp; year_weeknum::operator-=(const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this - dy</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr bool year_weeknum::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_.ok() &amp;&amp; 1_w &lt;= wn_ &amp;&amp; wn_ &lt;= (y_/last).weeknum()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() == y.year() &amp;&amp; x.weeknum() == y.weeknum()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() &lt; y.year() ? true
     : (x.year() &gt; y.year() ? false
     : (x.weeknum() &lt; y.weeknum()))</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const year_weeknum&amp; x, const year_weeknum&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum operator+(const year_weeknum&amp; ym, const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>(ym.year() + dy) / ym.weeknum()</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum operator+(const years&amp; dy, const year_weeknum&amp; ym) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>ym + dy</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum operator-(const year_weeknum&amp; ym, const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>ym + -dy</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_weeknum&amp; ywn);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; ywn.year() &lt;&lt; '-' &lt;&lt; ywn.weeknum()</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="year_lastweek"></a><h3><code>year_lastweek</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class year_lastweek
{
    iso_week::year y_;  // exposition only

public:
    explicit constexpr year_lastweek(const iso_week::year&amp; y) noexcept;

    constexpr iso_week::year    year()    const noexcept;
    constexpr iso_week::weeknum weeknum() const noexcept;

    year_lastweek&amp; operator+=(const years&amp; dy) noexcept;
    year_lastweek&amp; operator-=(const years&amp; dy) noexcept;

    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
constexpr bool operator!=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
constexpr bool operator&lt; (const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
constexpr bool operator&gt; (const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
constexpr bool operator&lt;=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
constexpr bool operator&gt;=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;

constexpr year_lastweek operator+(const year_lastweek&amp; ym, const years&amp; dy) noexcept;
constexpr year_lastweek operator+(const years&amp; dy, const year_lastweek&amp; ym) noexcept;
constexpr year_lastweek operator-(const year_lastweek&amp; ym, const years&amp; dy) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_lastweek&amp; ym);
</pre>

<p><b>Overview</b></p>

<p>
<code>year_lastweek</code> represents a ISO week <code>year</code> and the last week of
that year.  One can perform year-oriented arithmetic with a <code>year_lastweek</code>.  And
<code>year_lastweek</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>year_lastweek</code> is a trivially copyable class type.</br>
<code>year_lastweek</code> is a standard-layout class type.</br>
<code>year_lastweek</code> is a literal class type.</br>
</p>

<pre>
explicit constexpr year_lastweek::year_lastweek(const iso_week::year&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_lastweek</code> by constructing
<code>y_</code> with <code>y</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::year year_lastweek::year() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weeknum year_lastweek::weeknum() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> The ISO week number for the last week of the year <code>y_</code>.
</p>
</blockquote>

<pre>
year_lastweek&amp; year_lastweek::operator+=(const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this + dy</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year_lastweek&amp; year_lastweek::operator-=(const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>*this = *this - dy</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr bool year_lastweek::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_.ok()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() == y.year()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() &lt; y.year()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const year_lastweek&amp; x, const year_lastweek&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek operator+(const year_lastweek&amp; ym, const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>year_lastweek{ym.year() + dy}</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek operator+(const years&amp; dy, const year_lastweek&amp; ym) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>ym + dy</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek operator-(const year_lastweek&amp; ym, const years&amp; dy) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>ym + -dy</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_lastweek&amp; ywn);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; ywn.year() &lt;&lt; "-W last"</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="weeknum_weekday"></a><h3><code>weeknum_weekday</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class weeknum_weekday
{
    iso_week::weeknum wn_;  // exposition only
    iso_week::weekday wd_;  // exposition only

public:
    constexpr weeknum_weekday(const iso_week::weeknum&amp; wn,
                              const iso_week::weekday&amp; wd) noexcept;

    constexpr iso_week::weeknum weeknum() const noexcept;
    constexpr iso_week::weekday weekday() const noexcept;

    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
constexpr bool operator!=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
constexpr bool operator&lt; (const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
constexpr bool operator&gt; (const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
constexpr bool operator&lt;=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
constexpr bool operator&gt;=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weeknum_weekday&amp; md);
</pre>

<p><b>Overview</b></p>

<p>
<code>weeknum_weekday</code> is simply a collection of a <code>weeknum</code> and a
<code>weekday</code>.  It represents a specific week and day of the week, but an
unspecified year.  <code>weeknum_weekday</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>weeknum_weekday</code> is a trivially copyable class type.</br>
<code>weeknum_weekday</code> is a standard-layout class type.</br>
<code>weeknum_weekday</code> is a literal class type.</br>
</p>

<pre>
constexpr weeknum_weekday::weeknum_weekday(const iso_week::weeknum&amp; wn,
                                           const iso_week::weekday&amp; wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weeknum_weekday</code> by constructing
<code>wn_</code> with <code>wn</code> and <code>wd_</code> with <code>wd</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weeknum weeknum_weekday::weeknum() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wn_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weekday weeknum_weekday::weekday() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr bool weeknum_weekday::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wn_.ok() &amp;&amp; wd_.ok()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.weeknum() == y.weeknum() &amp;&amp; x.weekday() == y.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.weeknum() &lt; y.weeknum() ? true
     : (x.weeknum() &gt; y.weeknum() ? false
     : (unsigned{x.weekday()} &lt; unsigned{y.weekday()}))</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const weeknum_weekday&amp; x, const weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const weeknum_weekday&amp; md);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; md.weeknum() &lt;&lt; '-' &lt;&lt; md.weekday()</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="lastweek_weekday"></a><h3><code>lastweek_weekday</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class lastweek_weekday
{
    iso_week::weekday wd_;  // exposition only

public:
    explicit constexpr lastweek_weekday(const iso_week::weekday&amp; wd) noexcept;

    constexpr iso_week::weekday weekday() const noexcept;

    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
constexpr bool operator!=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
constexpr bool operator&lt; (const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
constexpr bool operator&gt; (const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
constexpr bool operator&lt;=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
constexpr bool operator&gt;=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const lastweek_weekday&amp; md);
</pre>

<p><b>Overview</b></p>

<p>
<code>lastweek_weekday</code> represents a weekday in the last week of an unspecified
year.  <code>lastweek_weekday</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>lastweek_weekday</code> is a trivially copyable class type.</br>
<code>lastweek_weekday</code> is a standard-layout class type.</br>
<code>lastweek_weekday</code> is a literal class type.</br>
</p>

<pre>
explicit constexpr lastweek_weekday::lastweek_weekday(const iso_week::weekday&amp; wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>lastweek_weekday</code> by constructing
<code>wd_</code> with <code>wd</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weekday lastweek_weekday::weekday() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr bool lastweek_weekday::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_.ok()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.weekday() == y.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>unsigned{x.weekday()} &lt; unsigned{y.weekday()}</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const lastweek_weekday&amp; x, const lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const lastweek_weekday&amp; md);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; "W last-" &lt;&lt; md.weekday()</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="year_weeknum_weekday"></a><h3><code>year_weeknum_weekday</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class year_weeknum_weekday
{
    iso_week::year    y_;   // exposition only
    iso_week::weeknum wn_;  // exposition only
    iso_week::weekday wd_;  // exposition only

public:
    constexpr year_weeknum_weekday(const iso_week::year&amp; y, const iso_week::weeknum&amp; wn,
                                   const iso_week::weekday&amp; wd) noexcept;
    constexpr year_weeknum_weekday(const year_lastweek_weekday&amp; x) noexcept;
    constexpr year_weeknum_weekday(const sys_days&amp; dp) noexcept;

    year_weeknum_weekday&amp; operator+=(const years&amp; y) noexcept;
    year_weeknum_weekday&amp; operator-=(const years&amp; y) noexcept;

    constexpr iso_week::year    year()    const noexcept;
    constexpr iso_week::weeknum weeknum() const noexcept;
    constexpr iso_week::weekday weekday() const noexcept;

    constexpr operator sys_days() const noexcept;
    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
constexpr bool operator!=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
constexpr bool operator&lt; (const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
constexpr bool operator&gt; (const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
constexpr bool operator&lt;=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
constexpr bool operator&gt;=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;

constexpr year_weeknum_weekday operator+(const year_weeknum_weekday&amp; x, const years&amp; y) noexcept;
constexpr year_weeknum_weekday operator+(const years&amp; y, const year_weeknum_weekday&amp; x) noexcept;
constexpr year_weeknum_weekday operator-(const year_weeknum_weekday&amp; x, const years&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_weeknum_weekday&amp; x);
</pre>

<p><b>Overview</b></p>

<p>
<code>year_weeknum_weekday</code> represents a <code>year</code>, <code>weeknum</code>,
and <code>weekday</code> in the
<a href="https://en.wikipedia.org/wiki/ISO_week_date">ISO week date calendar</a>.
One can observe each field. <code>year_weeknum_weekday</code> supports year-oriented
arithmetic. There is an implicit conversion to and from <code>sys_days</code>. There is
also an implicit conversion from <code>year_lastweek_weekday</code>.
<code>year_weeknum_weekday</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>year_weeknum_weekday</code> is a trivially copyable class type.</br>
<code>year_weeknum_weekday</code> is a standard-layout class type.</br>
<code>year_weeknum_weekday</code> is a literal class type.</br>
</p>

<pre>
constexpr year_weeknum_weekday::year_weeknum_weekday(const iso_week::year&amp; y,
                                                     const iso_week::weeknum&amp; wn,
                                                     const iso_week::weekday&amp; wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_weeknum_weekday</code> by
constructing <code>y_</code> with <code>y</code>, <code>wn_</code> with <code>wn</code>,
and <code>wd_</code> with <code>wd</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday::year_weeknum_weekday(const year_lastweek_weekday&amp; x) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_weeknum_weekday</code> by
constructing <code>y_</code> with <code>x.year()</code>, <code>wn_</code> with
<code>x.weeknum()</code>, and <code>wd_</code> with <code>x.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday::year_weeknum_weekday(const sys_days&amp; dp) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_weeknum_weekday</code> which
corresponds to the date represented by <code>dp</code>.
</p>
<p>
<i>Remarks:</i> For any value of <code>year_weeknum_weekday</code>, <code>x</code>, for
which <code>x.ok()</code> is <code>true</code>, this equality will also be
<code>true</code>: <code>x == year_weeknum_weekday{sys_days{x}}</code>.
</p>
</blockquote>

<pre>
year_weeknum_weekday&amp; year_weeknum_weekday::operator+=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effectx:</i> <code>*this = *this + y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year_weeknum_weekday&amp; year_weeknum_weekday::operator-=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effectx:</i> <code>*this = *this - y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::year year_weeknum_weekday::year() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weeknum year_weeknum_weekday::weeknum() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wn_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weekday year_weeknum_weekday::weekday() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday::operator sys_days() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> A <code>sys_days</code> which represents the date represented by
<code>*this</code>.
</p>
</blockquote>

<pre>
constexpr bool year_weeknum_weekday::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_.ok() &amp;&amp;
        wd_.ok() &amp;&amp;
        1_w &lt;= wn_ &amp;&amp; wn_ &lt;= year_lastweek{y_}.weeknum()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() == y.year() &amp;&amp;
        x.weeknum() == y.weeknum() &amp;&amp;
        x.weekday() == y.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() &lt; y.year() ? true
     : (x.year() &gt; y.year() ? false
     : (x.weeknum() &lt; y.weeknum() ? true
     : (x.weeknum() &gt; y.weeknum() ? false
     : (unsigned{x.weekday()} &lt; unsigned{y.weekday()}))))</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const year_weeknum_weekday&amp; x, const year_weeknum_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday operator+(const year_weeknum_weekday&amp; x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>(x.year() + y) / x.weeknum() / x.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday operator+(const years&amp; y, const year_weeknum_weekday&amp; x) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + y</code>.
</p>
</blockquote>

<pre>
constexpr year_weeknum_weekday operator-(const year_weeknum_weekday&amp; x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + -y</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_weeknum_weekday&amp; x);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; x.year() &lt;&lt; '-' &lt;&lt; x.weeknum() &lt;&lt; '-' &lt;&lt; x.weekday()</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<a name="year_lastweek_weekday"></a><h3><code>year_lastweek_weekday</code></h3>

<blockquote>
<p><b>Synopsis</b></p>

<pre>
class year_lastweek_weekday
{
    iso_week::year    y_;   // exposition only
    iso_week::weekday wd_;  // exposition only

public:
    constexpr year_lastweek_weekday(const iso_week::year&amp; y,
                                    const iso_week::weekday&amp; wd) noexcept;

    year_lastweek_weekday&amp; operator+=(const years&amp; y) noexcept;
    year_lastweek_weekday&amp; operator-=(const years&amp; y) noexcept;

    constexpr iso_week::year    year()    const noexcept;
    constexpr iso_week::weeknum weeknum() const noexcept;
    constexpr iso_week::weekday weekday() const noexcept;

    constexpr operator sys_days() const noexcept;
    constexpr bool ok() const noexcept;
};

constexpr bool operator==(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
constexpr bool operator!=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
constexpr bool operator&lt; (const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
constexpr bool operator&gt; (const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
constexpr bool operator&lt;=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
constexpr bool operator&gt;=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;

constexpr year_lastweek_weekday operator+(const year_lastweek_weekday&amp; x, const years&amp; y) noexcept;
constexpr year_lastweek_weekday operator+(const years&amp; y, const year_lastweek_weekday&amp; x) noexcept;
constexpr year_lastweek_weekday operator-(const year_lastweek_weekday&amp; x, const years&amp; y) noexcept;

std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_lastweek_weekday&amp; x);
</pre>

<p><b>Overview</b></p>

<p>
<code>year_lastweek_weekday</code> represents a <code>year</code>, 
and <code>weekday</code> in the last week of the
<a href="https://en.wikipedia.org/wiki/ISO_week_date">ISO week date calendar</a>.
One can observe each field. <code>year_lastweek_weekday</code> supports year-oriented
arithmetic. There is an implicit conversion to <code>sys_days</code>.
<code>year_lastweek_weekday</code> is equality and less-than comparable.
</p>

<p><b>Specification</b></p>

<p>
<code>year_lastweek_weekday</code> is a trivially copyable class type.</br>
<code>year_lastweek_weekday</code> is a standard-layout class type.</br>
<code>year_lastweek_weekday</code> is a literal class type.</br>
</p>

<pre>
constexpr year_lastweek_weekday::year_lastweek_weekday(const iso_week::year&amp; y,
                                                       const iso_week::weekday&amp; wd) noexcept;
</pre>

<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>year_lastweek_weekday</code> by
constructing <code>y_</code> with <code>y</code>, and <code>wd_</code> with
<code>wd</code>.
</p>
</blockquote>

<pre>
year_lastweek_weekday&amp; year_lastweek_weekday::operator+=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effectx:</i> <code>*this = *this + y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
year_lastweek_weekday&amp; year_lastweek_weekday::operator-=(const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Effectx:</i> <code>*this = *this - y</code>.
</p>
<p>
<i>Returns:</i> <code>*this</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::year year_lastweek_weekday::year() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weeknum year_lastweek_weekday::weeknum() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>(y_ / last).weeknum()</code>.
</p>
</blockquote>

<pre>
constexpr iso_week::weekday year_lastweek_weekday::weekday() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>wd_</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek_weekday::operator sys_days() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> A <code>sys_days</code> which represents the date represented by
<code>*this</code>.
</p>
</blockquote>

<pre>
constexpr bool year_lastweek_weekday::ok() const noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y_.ok() &amp;&amp; wd_.ok()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator==(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() == y.year() &amp;&amp; x.weekday() == y.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr bool operator!=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x == y)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x.year() &lt; y.year() ? true
     : (x.year() &gt; y.year() ? false
     : (unsigned{x.weekday()} &lt; unsigned{y.weekday()}))</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>y &lt; x</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&lt;=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(y &lt; x)</code>.
</p>
</blockquote>

<pre>
constexpr bool operator&gt;=(const year_lastweek_weekday&amp; x, const year_lastweek_weekday&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>!(x &lt; y)</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek_weekday operator+(const year_lastweek_weekday&amp; x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>(x.year() + y) / last / x.weekday()</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek_weekday operator+(const years&amp; y, const year_lastweek_weekday&amp; x) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + y</code>.
</p>
</blockquote>

<pre>
constexpr year_lastweek_weekday operator-(const year_lastweek_weekday&amp; x, const years&amp; y) noexcept;
</pre>

<blockquote>
<p>
<i>Returns:</i> <code>x + -y</code>.
</p>
</blockquote>

<pre>
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const year_lastweek_weekday&amp; x);
</pre>

<blockquote>
<p>
<i>Effects:</i> <code>os &lt;&lt; x.year() &lt;&lt; "-W last-" &lt;&lt; x.weekday()</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
</blockquote>

</blockquote>

<h3>date composition operators</h3>

<blockquote>

<p>
To understand this API it is not necessary for you to memorize each of these operators.
Indeed, that would be detrimental to understanding this API.  Instead it is sufficient
to known that this collection of operators implement constructions in 3 orders:
</p>

<ol>
<li><code>year/weeknum/weekday</code></li>
<li><code>weeknum/weekday/year</code></li>
<li><code>weekday/weeknum/year</code></li>
</ol>

<p>
The first component in each order must be properly typed, the following components may
be specified with the proper type or an <code>int</code>.
</p>

<p>
Anywhere a "weeknum" is required one can also specify <code>last</code> to indicate the
last week of the year.
</p>

<p>
Sub-field-types such as <code>year_weeknum</code> and <code>weeknum_weekday</code> can be
created by simply not applying the second division operator for any of the three orders. 
For example:
</p>

<blockquote><pre>
year_weeknum ym = 2015_y/52_w;
weeknum_weekday md1 = 52_w/thu;
weeknum_weekday md2 = thu/52_w;
</pre></blockquote>

<p>
Everything not intended as above is caught as a compile-time error, with the notable
exception of an expression that consists of nothing but <code>int</code>, which of course
has type <code>int</code>.
</p>

<blockquote><pre>
auto a = 2015/4/4;       // a == int(125)
auto b = 2015_y/4/4;     // b == year_weeknum_weekday{year(2015), week(4), weekday(4)}
auto c = 2015_y/thu/4_w; // error: invalid operands to binary expression ('iso_week::year' and 'iso_week::weekday')
auto d = 2015/4_w/4;     // error: invalid operands to binary expression ('int' and 'const iso_week::weeknum')
</pre></blockquote>

<p>
The last example may be clear to a human reader.  But the compiler doesn't know if
<code>2015</code> refers to a <code>year</code> or a <code>weekday</code>.  Instead of
guessing, the compiler flags it as an error.
</p>

<p>
In short, you will either write unambiguous and readable code, or you will get a
compile-time error.
</p>

<hr>

<p><b><code>year_weeknum</code>:</b></p>

<a name="_1"></a><pre>
constexpr year_weeknum operator/(const year&amp; y, const weeknum& wn) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{y, wn}</code>.
</blockquote>

<a name="_2"></a><pre>
constexpr year_weeknum operator/(const year&amp; y, int wn) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>y / weeknum(wn)</code>.
</blockquote>

<p><b><code>year_lastweek</code>:</b></p>

<a name="_3"></a><pre>
constexpr year_lastweek operator/(const year&amp; y, last_week) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>year_lastweek{y}</code>.
</blockquote>

<p><b><code>weeknum_weekday</code>:</b></p>

<a name="_4"></a><pre>
constexpr weeknum_weekday operator/(const weeknum&amp; wn, const weekday&amp; wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{wn, wd}</code>.
</blockquote>

<a name="_5"></a><pre>
constexpr weeknum_weekday operator/(const weeknum&amp; wn, int wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>wn / weekday{static_cast&lt;unsigned&gt;(wd)}</code>.
</blockquote>

<a name="_6"></a><pre>
constexpr weeknum_weekday operator/(const weekday&amp; wd, const weeknum&amp; wn) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>wn / wd</code>.
</blockquote>

<a name="_7"></a><pre>
constexpr weeknum_weekday operator/(const weekday&amp; wd, int wn) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>weeknum{static_cast&lt;unsigned&gt;(wn)} / wd</code>.
</blockquote>

<p><b><code>lastweek_weekday</code>:</b></p>

<a name="_8"></a><pre>
constexpr lastweek_weekday operator/(const last_week&amp;, const weekday&amp; wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>lastweek_weekday{wd}</code>.
</blockquote>

<a name="_9"></a><pre>
constexpr lastweek_weekday operator/(const last_week&amp; wn, int wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>wn / weekday{static_cast&lt;unsigned&gt;(wd)}</code>.
</blockquote>

<a name="_10"></a><pre>
constexpr lastweek_weekday operator/(const weekday&amp; wd, const last_week&amp; wn) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>wn / wd</code>.
</blockquote>

<p><b><code>year_weeknum_weekday</code>:</b></p>

<a name="_11"></a><pre>
constexpr year_weeknum_weekday operator/(const year_weeknum&amp; ywn, const weekday&amp; wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{ywn.year(), ywn.weeknum(), wd}</code>.
</blockquote>

<a name="_12"></a><pre>
constexpr year_weeknum_weekday operator/(const year_weeknum&amp; ywn, int wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>ywn / weekday{static_cast&lt;unsigned&gt;(wd)}</code>.
</blockquote>

<a name="_13"></a><pre>
constexpr year_weeknum_weekday operator/(const weeknum_weekday&amp; wnwd, const year&amp; y) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{y, wnwd.weeknum(), wnwd.weekday()}</code>.
</blockquote>

<a name="_14"></a><pre>
constexpr year_weeknum_weekday operator/(const weeknum_weekday&amp; wnwd, int y) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>wnwd / year{y}</code>.
</blockquote>

<p><b><code>year_lastweek_weekday</code>:</b></p>

<a name="_15"></a><pre>
constexpr year_lastweek_weekday operator/(const year_lastweek&amp; ylw, const weekday&amp; wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{ylw.year(), wd}</code>.
</blockquote>

<a name="_16"></a><pre>
constexpr year_lastweek_weekday operator/(const year_lastweek&amp; ylw, int wd) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>ylw / weekday{static_cast&lt;unsigned&gt;(wd)}</code>.
</blockquote>

<a name="_17"></a><pre>
constexpr year_lastweek_weekday operator/(const lastweek_weekday&amp; lwwd, const year&amp; y) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>{y, lwwd.weekday()}</code>.
</blockquote>

<a name="_18"></a><pre>
constexpr year_lastweek_weekday operator/(const lastweek_weekday&amp; lwwd, int y) noexcept;
</pre>

<blockquote>
<i>Returns:</i> <code>lwwd / year{y}</code>.
</blockquote>

</blockquote>

</body>
</html>