Dynalib Utils
iso_week.h
Go to the documentation of this file.
1 #ifndef ISO_WEEK_H
2 #define ISO_WEEK_H
3 
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2015, 2016, 2017 Howard Hinnant
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #include "date.h"
27 
28 #include <climits>
29 
30 namespace iso_week
31 {
32 
33 // y/wn/wd
34 // wn/wd/y
35 // wd/wn/y
36 
37 using days = date::days;
40 
41 // time_point
42 
45 
46 // types
47 
48 struct last_week
49 {
50  explicit last_week() = default;
51 };
52 
53 class weekday;
54 class weeknum;
55 class year;
56 
57 class year_weeknum;
58 class year_lastweek;
59 class weeknum_weekday;
60 class lastweek_weekday;
61 
64 
65 // date composition operators
66 
68 CONSTCD11 year_weeknum operator/(const year& y, int wn) NOEXCEPT;
69 
71 
76 
80 
85 
88 
91 
92 // weekday
93 
94 class weekday
95 {
96  unsigned char wd_;
97 public:
98  explicit CONSTCD11 weekday(unsigned wd) NOEXCEPT;
100  explicit weekday(int) = delete;
101  CONSTCD11 weekday(const sys_days& dp) NOEXCEPT;
102  CONSTCD11 explicit weekday(const local_days& dp) NOEXCEPT;
103 
104  weekday& operator++() NOEXCEPT;
105  weekday operator++(int) NOEXCEPT;
106  weekday& operator--() NOEXCEPT;
107  weekday operator--(int) NOEXCEPT;
108 
109  weekday& operator+=(const days& d) NOEXCEPT;
110  weekday& operator-=(const days& d) NOEXCEPT;
111 
112  CONSTCD11 explicit operator unsigned() const NOEXCEPT;
113  CONSTCD11 operator date::weekday() const NOEXCEPT;
114  CONSTCD11 bool ok() const NOEXCEPT;
115 
116 private:
117  static CONSTCD11 unsigned char weekday_from_days(int z) NOEXCEPT;
118  static CONSTCD11 unsigned char to_iso_encoding(unsigned char) NOEXCEPT;
119  static CONSTCD11 unsigned from_iso_encoding(unsigned) NOEXCEPT;
120 };
121 
122 CONSTCD11 bool operator==(const weekday& x, const weekday& y) NOEXCEPT;
123 CONSTCD11 bool operator!=(const weekday& x, const weekday& y) NOEXCEPT;
124 
125 CONSTCD14 weekday operator+(const weekday& x, const days& y) NOEXCEPT;
126 CONSTCD14 weekday operator+(const days& x, const weekday& y) NOEXCEPT;
127 CONSTCD14 weekday operator-(const weekday& x, const days& y) NOEXCEPT;
128 CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT;
129 
130 template<class CharT, class Traits>
131 std::basic_ostream<CharT, Traits>&
132 operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd);
133 
134 // year
135 
136 class year
137 {
138  short y_;
139 
140 public:
141  explicit CONSTCD11 year(int y) NOEXCEPT;
142 
143  year& operator++() NOEXCEPT;
144  year operator++(int) NOEXCEPT;
145  year& operator--() NOEXCEPT;
146  year operator--(int) NOEXCEPT;
147 
148  year& operator+=(const years& y) NOEXCEPT;
149  year& operator-=(const years& y) NOEXCEPT;
150 
151  CONSTCD11 explicit operator int() const NOEXCEPT;
152  CONSTCD11 bool ok() const NOEXCEPT;
153 
154  static CONSTCD11 year min() NOEXCEPT;
155  static CONSTCD11 year max() NOEXCEPT;
156 };
157 
158 CONSTCD11 bool operator==(const year& x, const year& y) NOEXCEPT;
159 CONSTCD11 bool operator!=(const year& x, const year& y) NOEXCEPT;
160 CONSTCD11 bool operator< (const year& x, const year& y) NOEXCEPT;
161 CONSTCD11 bool operator> (const year& x, const year& y) NOEXCEPT;
162 CONSTCD11 bool operator<=(const year& x, const year& y) NOEXCEPT;
163 CONSTCD11 bool operator>=(const year& x, const year& y) NOEXCEPT;
164 
165 CONSTCD11 year operator+(const year& x, const years& y) NOEXCEPT;
166 CONSTCD11 year operator+(const years& x, const year& y) NOEXCEPT;
167 CONSTCD11 year operator-(const year& x, const years& y) NOEXCEPT;
168 CONSTCD11 years operator-(const year& x, const year& y) NOEXCEPT;
169 
170 template<class CharT, class Traits>
171 std::basic_ostream<CharT, Traits>&
172 operator<<(std::basic_ostream<CharT, Traits>& os, const year& y);
173 
174 // weeknum
175 
176 class weeknum
177 {
178  unsigned char wn_;
179 
180 public:
181  explicit CONSTCD11 weeknum(unsigned wn) NOEXCEPT;
182 
183  weeknum& operator++() NOEXCEPT;
184  weeknum operator++(int) NOEXCEPT;
185  weeknum& operator--() NOEXCEPT;
186  weeknum operator--(int) NOEXCEPT;
187 
188  weeknum& operator+=(const weeks& y) NOEXCEPT;
189  weeknum& operator-=(const weeks& y) NOEXCEPT;
190 
191  CONSTCD11 explicit operator unsigned() const NOEXCEPT;
192  CONSTCD11 bool ok() const NOEXCEPT;
193 };
194 
195 CONSTCD11 bool operator==(const weeknum& x, const weeknum& y) NOEXCEPT;
196 CONSTCD11 bool operator!=(const weeknum& x, const weeknum& y) NOEXCEPT;
197 CONSTCD11 bool operator< (const weeknum& x, const weeknum& y) NOEXCEPT;
198 CONSTCD11 bool operator> (const weeknum& x, const weeknum& y) NOEXCEPT;
199 CONSTCD11 bool operator<=(const weeknum& x, const weeknum& y) NOEXCEPT;
200 CONSTCD11 bool operator>=(const weeknum& x, const weeknum& y) NOEXCEPT;
201 
202 CONSTCD11 weeknum operator+(const weeknum& x, const weeks& y) NOEXCEPT;
203 CONSTCD11 weeknum operator+(const weeks& x, const weeknum& y) NOEXCEPT;
204 CONSTCD11 weeknum operator-(const weeknum& x, const weeks& y) NOEXCEPT;
205 CONSTCD11 weeks operator-(const weeknum& x, const weeknum& y) NOEXCEPT;
206 
207 template<class CharT, class Traits>
208 std::basic_ostream<CharT, Traits>&
209 operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum& wn);
210 
211 // year_weeknum
212 
214 {
215  iso_week::year y_;
216  iso_week::weeknum wn_;
217 
218 public:
220 
223 
225  year_weeknum& operator-=(const years& dy) NOEXCEPT;
226 
227  CONSTCD11 bool ok() const NOEXCEPT;
228 };
229 
230 CONSTCD11 bool operator==(const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
231 CONSTCD11 bool operator!=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
232 CONSTCD11 bool operator< (const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
233 CONSTCD11 bool operator> (const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
234 CONSTCD11 bool operator<=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
235 CONSTCD11 bool operator>=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT;
236 
240 
241 template<class CharT, class Traits>
242 std::basic_ostream<CharT, Traits>&
243 operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum& ym);
244 
245 // year_lastweek
246 
248 {
249  iso_week::year y_;
250 
251 public:
252  CONSTCD11 explicit year_lastweek(const iso_week::year& y) NOEXCEPT;
253 
256 
258  year_lastweek& operator-=(const years& dy) NOEXCEPT;
259 
260  CONSTCD11 bool ok() const NOEXCEPT;
261 };
262 
263 CONSTCD11 bool operator==(const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
264 CONSTCD11 bool operator!=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
265 CONSTCD11 bool operator< (const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
266 CONSTCD11 bool operator> (const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
267 CONSTCD11 bool operator<=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
268 CONSTCD11 bool operator>=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT;
269 
273 
274 template<class CharT, class Traits>
275 std::basic_ostream<CharT, Traits>&
276 operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek& ym);
277 
278 // weeknum_weekday
279 
281 {
282  iso_week::weeknum wn_;
283  iso_week::weekday wd_;
284 
285 public:
287  const iso_week::weekday& wd) NOEXCEPT;
288 
291 
292  CONSTCD14 bool ok() const NOEXCEPT;
293 };
294 
301 
302 template<class CharT, class Traits>
303 std::basic_ostream<CharT, Traits>&
304 operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum_weekday& md);
305 
306 // lastweek_weekday
307 
309 {
310  iso_week::weekday wd_;
311 
312 public:
314 
316 
317  CONSTCD14 bool ok() const NOEXCEPT;
318 };
319 
326 
327 template<class CharT, class Traits>
328 std::basic_ostream<CharT, Traits>&
329 operator<<(std::basic_ostream<CharT, Traits>& os, const lastweek_weekday& md);
330 
331 // year_lastweek_weekday
332 
334 {
335  iso_week::year y_;
336  iso_week::weekday wd_;
337 
338 public:
340  const iso_week::weekday& wd) NOEXCEPT;
341 
343  year_lastweek_weekday& operator-=(const years& y) NOEXCEPT;
344 
348 
349  CONSTCD14 operator sys_days() const NOEXCEPT;
350  CONSTCD14 explicit operator local_days() const NOEXCEPT;
351  CONSTCD11 bool ok() const NOEXCEPT;
352 };
353 
360 
364 
365 template<class CharT, class Traits>
366 std::basic_ostream<CharT, Traits>&
367 operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek_weekday& ywnwd);
368 
369 // class year_weeknum_weekday
370 
372 {
373  iso_week::year y_;
374  iso_week::weeknum wn_;
375  iso_week::weekday wd_;
376 
377 public:
379  const iso_week::weekday& wd) NOEXCEPT;
383 
385  year_weeknum_weekday& operator-=(const years& y) NOEXCEPT;
386 
390 
391  CONSTCD14 operator sys_days() const NOEXCEPT;
392  CONSTCD14 explicit operator local_days() const NOEXCEPT;
393  CONSTCD14 bool ok() const NOEXCEPT;
394 
395 private:
396  static CONSTCD14 year_weeknum_weekday from_days(days dp) NOEXCEPT;
397 };
398 
405 
409 
410 template<class CharT, class Traits>
411 std::basic_ostream<CharT, Traits>&
412 operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum_weekday& ywnwd);
413 
414 //----------------+
415 // Implementation |
416 //----------------+
417 
418 // weekday
419 
420 CONSTCD11
421 inline
422 unsigned char
423 weekday::to_iso_encoding(unsigned char z) NOEXCEPT
424 {
425  return z != 0 ? z : (unsigned char)7;
426 }
427 
428 CONSTCD11
429 inline
430 unsigned
431 weekday::from_iso_encoding(unsigned z) NOEXCEPT
432 {
433  return z != 7 ? z : 0u;
434 }
435 
436 CONSTCD11
437 inline
438 unsigned char
439 weekday::weekday_from_days(int z) NOEXCEPT
440 {
441  return to_iso_encoding(static_cast<unsigned char>(static_cast<unsigned>(
442  z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6)));
443 }
444 
445 CONSTCD11
446 inline
448  : wd_(static_cast<decltype(wd_)>(wd))
449  {}
450 
451 CONSTCD11
452 inline
454  : wd_(to_iso_encoding(static_cast<unsigned>(wd)))
455  {}
456 
457 CONSTCD11
458 inline
460  : wd_(weekday_from_days(dp.time_since_epoch().count()))
461  {}
462 
463 CONSTCD11
464 inline
466  : wd_(weekday_from_days(dp.time_since_epoch().count()))
467  {}
468 
469 inline weekday& weekday::operator++() NOEXCEPT {if (++wd_ == 8) wd_ = 1; return *this;}
470 inline weekday weekday::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
471 inline weekday& weekday::operator--() NOEXCEPT {if (wd_-- == 1) wd_ = 7; return *this;}
472 inline weekday weekday::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
473 
474 inline
475 weekday&
476 weekday::operator+=(const days& d) NOEXCEPT
477 {
478  *this = *this + d;
479  return *this;
480 }
481 
482 inline
483 weekday&
484 weekday::operator-=(const days& d) NOEXCEPT
485 {
486  *this = *this - d;
487  return *this;
488 }
489 
490 CONSTCD11
491 inline
492 weekday::operator unsigned() const NOEXCEPT
493 {
494  return wd_;
495 }
496 
497 CONSTCD11
498 inline
499 weekday::operator date::weekday() const NOEXCEPT
500 {
501  return date::weekday{from_iso_encoding(unsigned{wd_})};
502 }
503 
504 CONSTCD11 inline bool weekday::ok() const NOEXCEPT {return 1 <= wd_ && wd_ <= 7;}
505 
506 CONSTCD11
507 inline
508 bool
509 operator==(const weekday& x, const weekday& y) NOEXCEPT
510 {
511  return static_cast<unsigned>(x) == static_cast<unsigned>(y);
512 }
513 
514 CONSTCD11
515 inline
516 bool
517 operator!=(const weekday& x, const weekday& y) NOEXCEPT
518 {
519  return !(x == y);
520 }
521 
522 CONSTCD14
523 inline
524 days
525 operator-(const weekday& x, const weekday& y) NOEXCEPT
526 {
527  auto const diff = static_cast<unsigned>(x) - static_cast<unsigned>(y);
528  return days{diff <= 6 ? diff : diff + 7};
529 }
530 
531 CONSTCD14
532 inline
533 weekday
534 operator+(const weekday& x, const days& y) NOEXCEPT
535 {
536  auto const wdu = static_cast<long long>(static_cast<unsigned>(x) - 1u) + y.count();
537  auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
538  return weekday{static_cast<unsigned>(wdu - wk * 7) + 1u};
539 }
540 
541 CONSTCD14
542 inline
543 weekday
544 operator+(const days& x, const weekday& y) NOEXCEPT
545 {
546  return y + x;
547 }
548 
549 CONSTCD14
550 inline
551 weekday
552 operator-(const weekday& x, const days& y) NOEXCEPT
553 {
554  return x + -y;
555 }
556 
557 template<class CharT, class Traits>
558 inline
559 std::basic_ostream<CharT, Traits>&
560 operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd)
561 {
562  switch (static_cast<unsigned>(wd))
563  {
564  case 7:
565  os << "Sun";
566  break;
567  case 1:
568  os << "Mon";
569  break;
570  case 2:
571  os << "Tue";
572  break;
573  case 3:
574  os << "Wed";
575  break;
576  case 4:
577  os << "Thu";
578  break;
579  case 5:
580  os << "Fri";
581  break;
582  case 6:
583  os << "Sat";
584  break;
585  default:
586  os << static_cast<unsigned>(wd) << " is not a valid weekday";
587  break;
588  }
589  return os;
590 }
591 
592 // year
593 
594 CONSTCD11 inline year::year(int y) NOEXCEPT : y_(static_cast<decltype(y_)>(y)) {}
595 inline year& year::operator++() NOEXCEPT {++y_; return *this;}
596 inline year year::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
597 inline year& year::operator--() NOEXCEPT {--y_; return *this;}
598 inline year year::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
599 inline year& year::operator+=(const years& y) NOEXCEPT {*this = *this + y; return *this;}
600 inline year& year::operator-=(const years& y) NOEXCEPT {*this = *this - y; return *this;}
601 
602 CONSTCD11 inline year::operator int() const NOEXCEPT {return y_;}
603 CONSTCD11 inline bool year::ok() const NOEXCEPT {return min() <= *this && *this <= max();}
604 
605 CONSTCD11
606 inline
607 year
608 year::min() NOEXCEPT
609 {
610  using namespace std::chrono;
611  static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
612  static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
613  return sizeof(minutes)*CHAR_BIT < 34 ?
614  year{1970} + duration_cast<years>(minutes::min()) :
615  year{std::numeric_limits<short>::min()};
616 }
617 
618 CONSTCD11
619 inline
620 year
621 year::max() NOEXCEPT
622 {
623  using namespace std::chrono;
624  static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
625  static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
626  return sizeof(minutes)*CHAR_BIT < 34 ?
627  year{1969} + duration_cast<years>(minutes::max()) :
628  year{std::numeric_limits<short>::max()};
629 }
630 
631 CONSTCD11
632 inline
633 bool
634 operator==(const year& x, const year& y) NOEXCEPT
635 {
636  return static_cast<int>(x) == static_cast<int>(y);
637 }
638 
639 CONSTCD11
640 inline
641 bool
642 operator!=(const year& x, const year& y) NOEXCEPT
643 {
644  return !(x == y);
645 }
646 
647 CONSTCD11
648 inline
649 bool
650 operator<(const year& x, const year& y) NOEXCEPT
651 {
652  return static_cast<int>(x) < static_cast<int>(y);
653 }
654 
655 CONSTCD11
656 inline
657 bool
658 operator>(const year& x, const year& y) NOEXCEPT
659 {
660  return y < x;
661 }
662 
663 CONSTCD11
664 inline
665 bool
666 operator<=(const year& x, const year& y) NOEXCEPT
667 {
668  return !(y < x);
669 }
670 
671 CONSTCD11
672 inline
673 bool
674 operator>=(const year& x, const year& y) NOEXCEPT
675 {
676  return !(x < y);
677 }
678 
679 CONSTCD11
680 inline
681 years
682 operator-(const year& x, const year& y) NOEXCEPT
683 {
684  return years{static_cast<int>(x) - static_cast<int>(y)};
685 }
686 
687 CONSTCD11
688 inline
689 year
690 operator+(const year& x, const years& y) NOEXCEPT
691 {
692  return year{static_cast<int>(x) + y.count()};
693 }
694 
695 CONSTCD11
696 inline
697 year
698 operator+(const years& x, const year& y) NOEXCEPT
699 {
700  return y + x;
701 }
702 
703 CONSTCD11
704 inline
705 year
706 operator-(const year& x, const years& y) NOEXCEPT
707 {
708  return year{static_cast<int>(x) - y.count()};
709 }
710 
711 template<class CharT, class Traits>
712 inline
713 std::basic_ostream<CharT, Traits>&
714 operator<<(std::basic_ostream<CharT, Traits>& os, const year& y)
715 {
717  os.fill('0');
718  os.flags(std::ios::dec | std::ios::internal);
719  os.width(4 + (y < year{0}));
720  os << static_cast<int>(y);
721  return os;
722 }
723 
724 #if !defined(_MSC_VER) || (_MSC_VER >= 1900)
725 inline namespace literals
726 {
727 
728 CONSTCD11
729 inline
731 operator "" _y(unsigned long long y) NOEXCEPT
732 {
733  return iso_week::year(static_cast<int>(y));
734 }
735 
736 CONSTCD11
737 inline
739 operator "" _w(unsigned long long wn) NOEXCEPT
740 {
741  return iso_week::weeknum(static_cast<unsigned>(wn));
742 }
743 
744 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
745 
747 
755 
756 #if !defined(_MSC_VER) || (_MSC_VER >= 1900)
757 } // inline namespace literals
758 #endif
759 
760 // weeknum
761 
762 CONSTCD11
763 inline
765  : wn_(static_cast<decltype(wn_)>(wn))
766  {}
767 
768 inline weeknum& weeknum::operator++() NOEXCEPT {++wn_; return *this;}
769 inline weeknum weeknum::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
770 inline weeknum& weeknum::operator--() NOEXCEPT {--wn_; return *this;}
771 inline weeknum weeknum::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
772 
773 inline
774 weeknum&
775 weeknum::operator+=(const weeks& y) NOEXCEPT
776 {
777  *this = *this + y;
778  return *this;
779 }
780 
781 inline
782 weeknum&
783 weeknum::operator-=(const weeks& y) NOEXCEPT
784 {
785  *this = *this - y;
786  return *this;
787 }
788 
789 CONSTCD11 inline weeknum::operator unsigned() const NOEXCEPT {return wn_;}
790 CONSTCD11 inline bool weeknum::ok() const NOEXCEPT {return 1 <= wn_ && wn_ <= 53;}
791 
792 CONSTCD11
793 inline
794 bool
795 operator==(const weeknum& x, const weeknum& y) NOEXCEPT
796 {
797  return static_cast<unsigned>(x) == static_cast<unsigned>(y);
798 }
799 
800 CONSTCD11
801 inline
802 bool
803 operator!=(const weeknum& x, const weeknum& y) NOEXCEPT
804 {
805  return !(x == y);
806 }
807 
808 CONSTCD11
809 inline
810 bool
811 operator<(const weeknum& x, const weeknum& y) NOEXCEPT
812 {
813  return static_cast<unsigned>(x) < static_cast<unsigned>(y);
814 }
815 
816 CONSTCD11
817 inline
818 bool
819 operator>(const weeknum& x, const weeknum& y) NOEXCEPT
820 {
821  return y < x;
822 }
823 
824 CONSTCD11
825 inline
826 bool
827 operator<=(const weeknum& x, const weeknum& y) NOEXCEPT
828 {
829  return !(y < x);
830 }
831 
832 CONSTCD11
833 inline
834 bool
835 operator>=(const weeknum& x, const weeknum& y) NOEXCEPT
836 {
837  return !(x < y);
838 }
839 
840 CONSTCD11
841 inline
842 weeks
843 operator-(const weeknum& x, const weeknum& y) NOEXCEPT
844 {
845  return weeks{static_cast<weeks::rep>(static_cast<unsigned>(x)) -
846  static_cast<weeks::rep>(static_cast<unsigned>(y))};
847 }
848 
849 CONSTCD11
850 inline
851 weeknum
852 operator+(const weeknum& x, const weeks& y) NOEXCEPT
853 {
854  return weeknum{static_cast<unsigned>(x) + static_cast<unsigned>(y.count())};
855 }
856 
857 CONSTCD11
858 inline
859 weeknum
860 operator+(const weeks& x, const weeknum& y) NOEXCEPT
861 {
862  return y + x;
863 }
864 
865 CONSTCD11
866 inline
867 weeknum
868 operator-(const weeknum& x, const weeks& y) NOEXCEPT
869 {
870  return x + -y;
871 }
872 
873 template<class CharT, class Traits>
874 inline
875 std::basic_ostream<CharT, Traits>&
876 operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum& wn)
877 {
879  os << 'W';
880  os.fill('0');
881  os.flags(std::ios::dec | std::ios::right);
882  os.width(2);
883  os << static_cast<unsigned>(wn);
884  return os;
885 }
886 
887 // year_weeknum
888 
889 CONSTCD11
890 inline
892  : y_(y)
893  , wn_(wn)
894  {}
895 
896 CONSTCD11 inline year year_weeknum::year() const NOEXCEPT {return y_;}
897 CONSTCD11 inline weeknum year_weeknum::weeknum() const NOEXCEPT {return wn_;}
898 CONSTCD11 inline bool year_weeknum::ok() const NOEXCEPT
899 {
900  return y_.ok() && 1u <= static_cast<unsigned>(wn_) && wn_ <= (y_/last).weeknum();
901 }
902 
903 inline
905 year_weeknum::operator+=(const years& dy) NOEXCEPT
906 {
907  *this = *this + dy;
908  return *this;
909 }
910 
911 inline
913 year_weeknum::operator-=(const years& dy) NOEXCEPT
914 {
915  *this = *this - dy;
916  return *this;
917 }
918 
919 CONSTCD11
920 inline
921 bool
922 operator==(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
923 {
924  return x.year() == y.year() && x.weeknum() == y.weeknum();
925 }
926 
927 CONSTCD11
928 inline
929 bool
930 operator!=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
931 {
932  return !(x == y);
933 }
934 
935 CONSTCD11
936 inline
937 bool
938 operator<(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
939 {
940  return x.year() < y.year() ? true
941  : (x.year() > y.year() ? false
942  : (x.weeknum() < y.weeknum()));
943 }
944 
945 CONSTCD11
946 inline
947 bool
948 operator>(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
949 {
950  return y < x;
951 }
952 
953 CONSTCD11
954 inline
955 bool
956 operator<=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
957 {
958  return !(y < x);
959 }
960 
961 CONSTCD11
962 inline
963 bool
964 operator>=(const year_weeknum& x, const year_weeknum& y) NOEXCEPT
965 {
966  return !(x < y);
967 }
968 
969 CONSTCD11
970 inline
972 operator+(const year_weeknum& ym, const years& dy) NOEXCEPT
973 {
974  return (ym.year() + dy) / ym.weeknum();
975 }
976 
977 CONSTCD11
978 inline
980 operator+(const years& dy, const year_weeknum& ym) NOEXCEPT
981 {
982  return ym + dy;
983 }
984 
985 CONSTCD11
986 inline
988 operator-(const year_weeknum& ym, const years& dy) NOEXCEPT
989 {
990  return ym + -dy;
991 }
992 
993 template<class CharT, class Traits>
994 inline
995 std::basic_ostream<CharT, Traits>&
996 operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum& ywn)
997 {
998  return os << ywn.year() << '-' << ywn.weeknum();
999 }
1000 
1001 
1002 // year_lastweek
1003 
1004 CONSTCD11
1005 inline
1007  : y_(y)
1008  {}
1009 
1010 CONSTCD11 inline year year_lastweek::year() const NOEXCEPT {return y_;}
1011 
1012 CONSTCD14
1013 inline
1014 weeknum
1015 year_lastweek::weeknum() const NOEXCEPT
1016 {
1017  const auto y = date::year{static_cast<int>(y_)};
1018  const auto s0 = sys_days((y-years{1})/12/date::thu[date::last]);
1019  const auto s1 = sys_days(y/12/date::thu[date::last]);
1020  return iso_week::weeknum(static_cast<unsigned>(date::trunc<weeks>(s1-s0).count()));
1021 }
1022 
1023 CONSTCD11 inline bool year_lastweek::ok() const NOEXCEPT {return y_.ok();}
1024 
1025 inline
1028 {
1029  *this = *this + dy;
1030  return *this;
1031 }
1032 
1033 inline
1036 {
1037  *this = *this - dy;
1038  return *this;
1039 }
1040 
1041 CONSTCD11
1042 inline
1043 bool
1044 operator==(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1045 {
1046  return x.year() == y.year();
1047 }
1048 
1049 CONSTCD11
1050 inline
1051 bool
1052 operator!=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1053 {
1054  return !(x == y);
1055 }
1056 
1057 CONSTCD11
1058 inline
1059 bool
1060 operator<(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1061 {
1062  return x.year() < y.year();
1063 }
1064 
1065 CONSTCD11
1066 inline
1067 bool
1068 operator>(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1069 {
1070  return y < x;
1071 }
1072 
1073 CONSTCD11
1074 inline
1075 bool
1076 operator<=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1077 {
1078  return !(y < x);
1079 }
1080 
1081 CONSTCD11
1082 inline
1083 bool
1084 operator>=(const year_lastweek& x, const year_lastweek& y) NOEXCEPT
1085 {
1086  return !(x < y);
1087 }
1088 
1089 CONSTCD11
1090 inline
1092 operator+(const year_lastweek& ym, const years& dy) NOEXCEPT
1093 {
1094  return year_lastweek{ym.year() + dy};
1095 }
1096 
1097 CONSTCD11
1098 inline
1100 operator+(const years& dy, const year_lastweek& ym) NOEXCEPT
1101 {
1102  return ym + dy;
1103 }
1104 
1105 CONSTCD11
1106 inline
1108 operator-(const year_lastweek& ym, const years& dy) NOEXCEPT
1109 {
1110  return ym + -dy;
1111 }
1112 
1113 template<class CharT, class Traits>
1114 inline
1115 std::basic_ostream<CharT, Traits>&
1116 operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek& ywn)
1117 {
1118  return os << ywn.year() << "-W last";
1119 }
1120 
1121 // weeknum_weekday
1122 
1123 CONSTCD11
1124 inline
1126  const iso_week::weekday& wd) NOEXCEPT
1127  : wn_(wn)
1128  , wd_(wd)
1129  {}
1130 
1131 CONSTCD11 inline weeknum weeknum_weekday::weeknum() const NOEXCEPT {return wn_;}
1132 CONSTCD11 inline weekday weeknum_weekday::weekday() const NOEXCEPT {return wd_;}
1133 
1134 CONSTCD14
1135 inline
1136 bool
1137 weeknum_weekday::ok() const NOEXCEPT
1138 {
1139  return wn_.ok() && wd_.ok();
1140 }
1141 
1142 CONSTCD11
1143 inline
1144 bool
1145 operator==(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1146 {
1147  return x.weeknum() == y.weeknum() && x.weekday() == y.weekday();
1148 }
1149 
1150 CONSTCD11
1151 inline
1152 bool
1153 operator!=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1154 {
1155  return !(x == y);
1156 }
1157 
1158 CONSTCD11
1159 inline
1160 bool
1161 operator<(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1162 {
1163  return x.weeknum() < y.weeknum() ? true
1164  : (x.weeknum() > y.weeknum() ? false
1165  : (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())));
1166 }
1167 
1168 CONSTCD11
1169 inline
1170 bool
1171 operator>(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1172 {
1173  return y < x;
1174 }
1175 
1176 CONSTCD11
1177 inline
1178 bool
1179 operator<=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1180 {
1181  return !(y < x);
1182 }
1183 
1184 CONSTCD11
1185 inline
1186 bool
1187 operator>=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
1188 {
1189  return !(x < y);
1190 }
1191 
1192 template<class CharT, class Traits>
1193 inline
1194 std::basic_ostream<CharT, Traits>&
1195 operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum_weekday& md)
1196 {
1197  return os << md.weeknum() << '-' << md.weekday();
1198 }
1199 
1200 // lastweek_weekday
1201 
1202 CONSTCD11
1203 inline
1205  : wd_(wd)
1206  {}
1207 
1208 CONSTCD11 inline weekday lastweek_weekday::weekday() const NOEXCEPT {return wd_;}
1209 
1210 CONSTCD14
1211 inline
1212 bool
1213 lastweek_weekday::ok() const NOEXCEPT
1214 {
1215  return wd_.ok();
1216 }
1217 
1218 CONSTCD11
1219 inline
1220 bool
1221 operator==(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1222 {
1223  return x.weekday() == y.weekday();
1224 }
1225 
1226 CONSTCD11
1227 inline
1228 bool
1229 operator!=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1230 {
1231  return !(x == y);
1232 }
1233 
1234 CONSTCD11
1235 inline
1236 bool
1237 operator<(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1238 {
1239  return static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday());
1240 }
1241 
1242 CONSTCD11
1243 inline
1244 bool
1245 operator>(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1246 {
1247  return y < x;
1248 }
1249 
1250 CONSTCD11
1251 inline
1252 bool
1253 operator<=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1254 {
1255  return !(y < x);
1256 }
1257 
1258 CONSTCD11
1259 inline
1260 bool
1261 operator>=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
1262 {
1263  return !(x < y);
1264 }
1265 
1266 template<class CharT, class Traits>
1267 inline
1268 std::basic_ostream<CharT, Traits>&
1269 operator<<(std::basic_ostream<CharT, Traits>& os, const lastweek_weekday& md)
1270 {
1271  return os << "W last-" << md.weekday();
1272 }
1273 
1274 // year_lastweek_weekday
1275 
1276 CONSTCD11
1277 inline
1279  const iso_week::weekday& wd) NOEXCEPT
1280  : y_(y)
1281  , wd_(wd)
1282  {}
1283 
1284 inline
1287 {
1288  *this = *this + y;
1289  return *this;
1290 }
1291 
1292 inline
1295 {
1296  *this = *this - y;
1297  return *this;
1298 }
1299 
1300 CONSTCD11 inline year year_lastweek_weekday::year() const NOEXCEPT {return y_;}
1301 
1302 CONSTCD14
1303 inline
1304 weeknum
1306 {
1307  return (y_ / last).weeknum();
1308 }
1309 
1310 CONSTCD11 inline weekday year_lastweek_weekday::weekday() const NOEXCEPT {return wd_;}
1311 
1312 CONSTCD14
1313 inline
1314 year_lastweek_weekday::operator sys_days() const NOEXCEPT
1315 {
1316  return sys_days(date::year{static_cast<int>(y_)}/date::dec/date::thu[date::last])
1317  + (sun - thu) - (sun - wd_);
1318 }
1319 
1320 CONSTCD14
1321 inline
1322 year_lastweek_weekday::operator local_days() const NOEXCEPT
1323 {
1324  return local_days(date::year{static_cast<int>(y_)}/date::dec/date::thu[date::last])
1325  + (sun - thu) - (sun - wd_);
1326 }
1327 
1328 CONSTCD11
1329 inline
1330 bool
1332 {
1333  return y_.ok() && wd_.ok();
1334 }
1335 
1336 CONSTCD11
1337 inline
1338 bool
1340 {
1341  return x.year() == y.year() && x.weekday() == y.weekday();
1342 }
1343 
1344 CONSTCD11
1345 inline
1346 bool
1348 {
1349  return !(x == y);
1350 }
1351 
1352 CONSTCD11
1353 inline
1354 bool
1356 {
1357  return x.year() < y.year() ? true
1358  : (x.year() > y.year() ? false
1359  : (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())));
1360 }
1361 
1362 CONSTCD11
1363 inline
1364 bool
1366 {
1367  return y < x;
1368 }
1369 
1370 CONSTCD11
1371 inline
1372 bool
1374 {
1375  return !(y < x);
1376 }
1377 
1378 CONSTCD11
1379 inline
1380 bool
1382 {
1383  return !(x < y);
1384 }
1385 
1386 CONSTCD11
1387 inline
1389 operator+(const year_lastweek_weekday& ywnwd, const years& y) NOEXCEPT
1390 {
1391  return (ywnwd.year() + y) / last / ywnwd.weekday();
1392 }
1393 
1394 CONSTCD11
1395 inline
1397 operator+(const years& y, const year_lastweek_weekday& ywnwd) NOEXCEPT
1398 {
1399  return ywnwd + y;
1400 }
1401 
1402 CONSTCD11
1403 inline
1405 operator-(const year_lastweek_weekday& ywnwd, const years& y) NOEXCEPT
1406 {
1407  return ywnwd + -y;
1408 }
1409 
1410 template<class CharT, class Traits>
1411 inline
1412 std::basic_ostream<CharT, Traits>&
1413 operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek_weekday& ywnwd)
1414 {
1415  return os << ywnwd.year() << "-W last-" << ywnwd.weekday();
1416 }
1417 
1418 // year_weeknum_weekday
1419 
1420 CONSTCD11
1421 inline
1423  const iso_week::weeknum& wn,
1424  const iso_week::weekday& wd) NOEXCEPT
1425  : y_(y)
1426  , wn_(wn)
1427  , wd_(wd)
1428  {}
1429 
1430 CONSTCD14
1431 inline
1433  : y_(ylwwd.year())
1434  , wn_(ylwwd.weeknum())
1435  , wd_(ylwwd.weekday())
1436  {}
1437 
1438 CONSTCD14
1439 inline
1441  : year_weeknum_weekday(from_days(dp.time_since_epoch()))
1442  {}
1443 
1444 CONSTCD14
1445 inline
1447  : year_weeknum_weekday(from_days(dp.time_since_epoch()))
1448  {}
1449 
1450 inline
1453 {
1454  *this = *this + y;
1455  return *this;
1456 }
1457 
1458 inline
1461 {
1462  *this = *this - y;
1463  return *this;
1464 }
1465 
1466 CONSTCD11 inline year year_weeknum_weekday::year() const NOEXCEPT {return y_;}
1467 CONSTCD11 inline weeknum year_weeknum_weekday::weeknum() const NOEXCEPT {return wn_;}
1468 CONSTCD11 inline weekday year_weeknum_weekday::weekday() const NOEXCEPT {return wd_;}
1469 
1470 CONSTCD14
1471 inline
1472 year_weeknum_weekday::operator sys_days() const NOEXCEPT
1473 {
1474  return sys_days(date::year{static_cast<int>(y_)-1}/date::dec/date::thu[date::last])
1475  + (date::mon - date::thu) + weeks{static_cast<unsigned>(wn_)-1} + (wd_ - mon);
1476 }
1477 
1478 CONSTCD14
1479 inline
1480 year_weeknum_weekday::operator local_days() const NOEXCEPT
1481 {
1482  return local_days(date::year{static_cast<int>(y_)-1}/date::dec/date::thu[date::last])
1483  + (date::mon - date::thu) + weeks{static_cast<unsigned>(wn_)-1} + (wd_ - mon);
1484 }
1485 
1486 CONSTCD14
1487 inline
1488 bool
1490 {
1491  return y_.ok() && wd_.ok() && iso_week::weeknum{1u} <= wn_ && wn_ <= year_lastweek{y_}.weeknum();
1492 }
1493 
1494 CONSTCD14
1495 inline
1497 year_weeknum_weekday::from_days(days d) NOEXCEPT
1498 {
1499  const auto dp = sys_days{d};
1500  const auto wd = iso_week::weekday{dp};
1501  auto y = date::year_month_day{dp + days{3}}.year();
1502  auto start = sys_days((y - date::years{1})/date::dec/date::thu[date::last]) + (mon-thu);
1503  if (dp < start)
1504  {
1505  --y;
1506  start = sys_days((y - date::years{1})/date::dec/date::thu[date::last]) + (mon-thu);
1507  }
1508  const auto wn = iso_week::weeknum(
1509  static_cast<unsigned>(date::trunc<weeks>(dp - start).count() + 1));
1510  return {iso_week::year(static_cast<int>(y)), wn, wd};
1511 }
1512 
1513 CONSTCD11
1514 inline
1515 bool
1517 {
1518  return x.year() == y.year() && x.weeknum() == y.weeknum() && x.weekday() == y.weekday();
1519 }
1520 
1521 CONSTCD11
1522 inline
1523 bool
1525 {
1526  return !(x == y);
1527 }
1528 
1529 CONSTCD11
1530 inline
1531 bool
1533 {
1534  return x.year() < y.year() ? true
1535  : (x.year() > y.year() ? false
1536  : (x.weeknum() < y.weeknum() ? true
1537  : (x.weeknum() > y.weeknum() ? false
1538  : (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())))));
1539 }
1540 
1541 CONSTCD11
1542 inline
1543 bool
1545 {
1546  return y < x;
1547 }
1548 
1549 CONSTCD11
1550 inline
1551 bool
1553 {
1554  return !(y < x);
1555 }
1556 
1557 CONSTCD11
1558 inline
1559 bool
1561 {
1562  return !(x < y);
1563 }
1564 
1565 CONSTCD11
1566 inline
1568 operator+(const year_weeknum_weekday& ywnwd, const years& y) NOEXCEPT
1569 {
1570  return (ywnwd.year() + y) / ywnwd.weeknum() / ywnwd.weekday();
1571 }
1572 
1573 CONSTCD11
1574 inline
1576 operator+(const years& y, const year_weeknum_weekday& ywnwd) NOEXCEPT
1577 {
1578  return ywnwd + y;
1579 }
1580 
1581 CONSTCD11
1582 inline
1584 operator-(const year_weeknum_weekday& ywnwd, const years& y) NOEXCEPT
1585 {
1586  return ywnwd + -y;
1587 }
1588 
1589 template<class CharT, class Traits>
1590 inline
1591 std::basic_ostream<CharT, Traits>&
1592 operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum_weekday& ywnwd)
1593 {
1594  return os << ywnwd.year() << '-' << ywnwd.weeknum() << '-' << ywnwd.weekday();
1595 }
1596 
1597 // date composition operators
1598 
1599 CONSTCD11
1600 inline
1602 operator/(const year& y, const weeknum& wn) NOEXCEPT
1603 {
1604  return {y, wn};
1605 }
1606 
1607 CONSTCD11
1608 inline
1610 operator/(const year& y, int wn) NOEXCEPT
1611 {
1612  return y/weeknum(static_cast<unsigned>(wn));
1613 }
1614 
1615 CONSTCD11
1616 inline
1618 operator/(const year& y, last_week) NOEXCEPT
1619 {
1620  return year_lastweek{y};
1621 }
1622 
1623 CONSTCD11
1624 inline
1626 operator/(const weeknum& wn, const weekday& wd) NOEXCEPT
1627 {
1628  return {wn, wd};
1629 }
1630 
1631 CONSTCD11
1632 inline
1634 operator/(const weeknum& wn, int wd) NOEXCEPT
1635 {
1636  return wn/weekday{static_cast<unsigned>(wd)};
1637 }
1638 
1639 CONSTCD11
1640 inline
1642 operator/(const weekday& wd, const weeknum& wn) NOEXCEPT
1643 {
1644  return wn/wd;
1645 }
1646 
1647 CONSTCD11
1648 inline
1650 operator/(const weekday& wd, int wn) NOEXCEPT
1651 {
1652  return weeknum{static_cast<unsigned>(wn)}/wd;
1653 }
1654 
1655 CONSTCD11
1656 inline
1658 operator/(const last_week&, const weekday& wd) NOEXCEPT
1659 {
1660  return lastweek_weekday{wd};
1661 }
1662 
1663 CONSTCD11
1664 inline
1666 operator/(const last_week& wn, int wd) NOEXCEPT
1667 {
1668  return wn / weekday{static_cast<unsigned>(wd)};
1669 }
1670 
1671 CONSTCD11
1672 inline
1674 operator/(const weekday& wd, const last_week& wn) NOEXCEPT
1675 {
1676  return wn / wd;
1677 }
1678 
1679 CONSTCD11
1680 inline
1682 operator/(const year_weeknum& ywn, const weekday& wd) NOEXCEPT
1683 {
1684  return {ywn.year(), ywn.weeknum(), wd};
1685 }
1686 
1687 CONSTCD11
1688 inline
1690 operator/(const year_weeknum& ywn, int wd) NOEXCEPT
1691 {
1692  return ywn / weekday(static_cast<unsigned>(wd));
1693 }
1694 
1695 CONSTCD11
1696 inline
1698 operator/(const weeknum_weekday& wnwd, const year& y) NOEXCEPT
1699 {
1700  return {y, wnwd.weeknum(), wnwd.weekday()};
1701 }
1702 
1703 CONSTCD11
1704 inline
1706 operator/(const weeknum_weekday& wnwd, int y) NOEXCEPT
1707 {
1708  return wnwd / year{y};
1709 }
1710 
1711 CONSTCD11
1712 inline
1714 operator/(const year_lastweek& ylw, const weekday& wd) NOEXCEPT
1715 {
1716  return {ylw.year(), wd};
1717 }
1718 
1719 CONSTCD11
1720 inline
1722 operator/(const year_lastweek& ylw, int wd) NOEXCEPT
1723 {
1724  return ylw / weekday(static_cast<unsigned>(wd));
1725 }
1726 
1727 CONSTCD11
1728 inline
1730 operator/(const lastweek_weekday& lwwd, const year& y) NOEXCEPT
1731 {
1732  return {y, lwwd.weekday()};
1733 }
1734 
1735 CONSTCD11
1736 inline
1738 operator/(const lastweek_weekday& lwwd, int y) NOEXCEPT
1739 {
1740  return lwwd / year{y};
1741 }
1742 
1743 } // namespace iso_week
1744 
1745 #endif // ISO_WEEK_H
Definition: date.h:638
CONSTCD11 iso_week::weeknum weeknum() const NOEXCEPT
Definition: iso_week.h:1131
year_weeknum & operator+=(const years &dy) NOEXCEPT
Definition: iso_week.h:905
CONSTCD14 bool ok() const NOEXCEPT
Definition: iso_week.h:1489
year & operator-=(const years &y) NOEXCEPT
Definition: iso_week.h:600
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:603
CONSTDATA date::month dec
Definition: date.h:1847
local_time< days > local_days
Definition: date.h:172
CONSTCD11 year_weeknum_weekday(const iso_week::year &y, const iso_week::weeknum &wn, const iso_week::weekday &wd) NOEXCEPT
Definition: iso_week.h:1422
CONSTCD14 weekday operator-(const weekday &x, const days &y) NOEXCEPT
Definition: iso_week.h:552
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:1023
CONSTDATA iso_week::weekday fri
Definition: iso_week.h:753
CONSTCD14 bool ok() const NOEXCEPT
Definition: iso_week.h:1137
#define NOEXCEPT
Definition: date.h:124
Definition: iso_week.h:48
date::local_days local_days
Definition: iso_week.h:44
CONSTCD11 year_weeknum(const iso_week::year &y, const iso_week::weeknum &wn) NOEXCEPT
Definition: iso_week.h:891
Definition: iso_week.h:333
Definition: iso_week.h:280
CONSTCD11 date::year year() const NOEXCEPT
Definition: date.h:2617
static CONSTCD11 year max() NOEXCEPT
Definition: iso_week.h:621
std::chrono::duration< int, std::ratio_multiply< std::ratio< 146097, 400 >, days::period > > years
Definition: date.h:153
weeknum & operator-=(const weeks &y) NOEXCEPT
Definition: iso_week.h:783
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT
Definition: iso_week.h:1310
CONSTCD11 year(int y) NOEXCEPT
Definition: iso_week.h:594
weeknum & operator--() NOEXCEPT
Definition: iso_week.h:770
Definition: iso_week.h:94
weekday & operator-=(const days &d) NOEXCEPT
Definition: iso_week.h:484
CONSTDATA iso_week::weekday wed
Definition: iso_week.h:751
sys_time< days > sys_days
Definition: date.h:163
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT
Definition: iso_week.h:1132
year_lastweek_weekday & operator-=(const years &y) NOEXCEPT
Definition: iso_week.h:1294
CONSTCD14 bool ok() const NOEXCEPT
Definition: iso_week.h:1213
Definition: date.h:365
CONSTCD11 weeknum(unsigned wn) NOEXCEPT
Definition: iso_week.h:764
CONSTCD11 bool operator<(const year &x, const year &y) NOEXCEPT
Definition: iso_week.h:650
Definition: iso_week.h:30
std::chrono::duration< int, std::ratio_multiply< std::ratio< 7 >, days::period > > weeks
Definition: date.h:150
CONSTDATA iso_week::last_week last
Definition: iso_week.h:746
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:898
CONSTCD11 iso_week::weeknum weeknum() const NOEXCEPT
Definition: iso_week.h:1467
weekday & operator++() NOEXCEPT
Definition: iso_week.h:469
CONSTCD11 bool operator==(const weekday &x, const weekday &y) NOEXCEPT
Definition: iso_week.h:509
CONSTCD11 iso_week::year year() const NOEXCEPT
Definition: iso_week.h:896
CONSTCD11 bool operator<=(const year &x, const year &y) NOEXCEPT
Definition: iso_week.h:666
CONSTCD11 iso_week::year year() const NOEXCEPT
Definition: iso_week.h:1300
CONSTCD11 weekday(unsigned wd) NOEXCEPT
Definition: iso_week.h:447
CONSTCD11 year_lastweek_weekday(const iso_week::year &y, const iso_week::weekday &wd) NOEXCEPT
Definition: iso_week.h:1278
weekday & operator--() NOEXCEPT
Definition: iso_week.h:471
CONSTCD11 weeknum_weekday(const iso_week::weeknum &wn, const iso_week::weekday &wd) NOEXCEPT
Definition: iso_week.h:1125
weeknum & operator+=(const weeks &y) NOEXCEPT
Definition: iso_week.h:775
CONSTDATA iso_week::weekday thu
Definition: iso_week.h:752
year_lastweek_weekday & operator+=(const years &y) NOEXCEPT
Definition: iso_week.h:1286
std::chrono::duration< int, std::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > > days
Definition: date.h:147
#define CONSTDATA
Definition: date.h:121
Definition: iso_week.h:247
date::days days
Definition: iso_week.h:37
Definition: iso_week.h:371
CONSTCD11 bool operator>=(const year &x, const year &y) NOEXCEPT
Definition: iso_week.h:674
date::weeks weeks
Definition: iso_week.h:38
Definition: iso_week.h:213
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT
Definition: iso_week.h:1468
date::sys_days sys_days
Definition: iso_week.h:43
year & operator+=(const years &y) NOEXCEPT
Definition: iso_week.h:599
year & operator++() NOEXCEPT
Definition: iso_week.h:595
year_weeknum & operator-=(const years &dy) NOEXCEPT
Definition: iso_week.h:913
#define CONSTCD14
Definition: date.h:123
date::years years
Definition: iso_week.h:39
auto operator+=(std::string &lhs, StringRef const &sr) -> std::string &
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:504
Definition: iso_week.h:176
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:1331
CONSTCD11 lastweek_weekday(const iso_week::weekday &wd) NOEXCEPT
Definition: iso_week.h:1204
CONSTCD14 weekday operator+(const weekday &x, const days &y) NOEXCEPT
Definition: iso_week.h:534
CONSTDATA iso_week::weekday sun
Definition: iso_week.h:748
CONSTCD11 iso_week::year year() const NOEXCEPT
Definition: iso_week.h:1010
CONSTCD14 iso_week::weeknum weeknum() const NOEXCEPT
Definition: iso_week.h:1305
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT
Definition: iso_week.h:1208
CONSTDATA iso_week::weekday mon
Definition: iso_week.h:749
weeknum & operator++() NOEXCEPT
Definition: iso_week.h:768
year_weeknum_weekday & operator+=(const years &y) NOEXCEPT
Definition: iso_week.h:1452
year & operator--() NOEXCEPT
Definition: iso_week.h:597
CONSTCD11 bool operator!=(const weekday &x, const weekday &y) NOEXCEPT
Definition: iso_week.h:517
CONSTDATA iso_week::weekday sat
Definition: iso_week.h:754
CONSTCD11 bool ok() const NOEXCEPT
Definition: iso_week.h:790
Definition: date.h:945
CONSTCD14 iso_week::weeknum weeknum() const NOEXCEPT
Definition: iso_week.h:1015
year_weeknum_weekday & operator-=(const years &y) NOEXCEPT
Definition: iso_week.h:1460
CONSTCD11 year_weeknum operator/(const year &y, const weeknum &wn) NOEXCEPT
Definition: iso_week.h:1602
CONSTDATA iso_week::weekday tue
Definition: iso_week.h:750
year_lastweek & operator+=(const years &dy) NOEXCEPT
Definition: iso_week.h:1027
Definition: iso_week.h:136
weekday & operator+=(const days &d) NOEXCEPT
Definition: iso_week.h:476
Definition: date.h:411
CONSTCD11 year_lastweek(const iso_week::year &y) NOEXCEPT
Definition: iso_week.h:1006
CONSTCD11 bool operator>(const year &x, const year &y) NOEXCEPT
Definition: iso_week.h:658
CONSTCD11 iso_week::year year() const NOEXCEPT
Definition: iso_week.h:1466
Definition: iso_week.h:308
year_lastweek & operator-=(const years &dy) NOEXCEPT
Definition: iso_week.h:1035
CONSTCD11 iso_week::weeknum weeknum() const NOEXCEPT
Definition: iso_week.h:897
static CONSTCD11 year min() NOEXCEPT
Definition: iso_week.h:608
#define CONSTCD11
Definition: date.h:122