NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
julian.h
Go to the documentation of this file.
1#ifndef JULIAN_H
2#define JULIAN_H
3
4// The MIT License (MIT)
5//
6// Copyright (c) 2016 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// Our apologies. When the previous paragraph was written, lowercase had not yet
27// been invented (that would involve another several millennia of evolution).
28// We did not mean to shout.
29
30#include "date.h"
31
32namespace julian
33{
34
35// durations
36
38
40
41using years = std::chrono::duration
43
44using months = std::chrono::duration
46
47// time_point
48
51
52// types
53
55{
56 explicit last_spec() = default;
57};
58
59class day;
60class month;
61class year;
62
63class weekday;
64class weekday_indexed;
65class weekday_last;
66
67class month_day;
68class month_day_last;
69class month_weekday;
71
72class year_month;
73
74class year_month_day;
78
79// date composition operators
80
83
84CONSTCD11 month_day operator/(const day& d, const month& m) NOEXCEPT;
86CONSTCD11 month_day operator/(const month& m, const day& d) NOEXCEPT;
89
94
99
104
111
122
125operator/(const year_month& ym, const weekday_indexed& wdi) NOEXCEPT;
126
129operator/(const year& y, const month_weekday& mwd) NOEXCEPT;
130
133operator/(int y, const month_weekday& mwd) NOEXCEPT;
134
137operator/(const month_weekday& mwd, const year& y) NOEXCEPT;
138
141operator/(const month_weekday& mwd, int y) NOEXCEPT;
142
145operator/(const year_month& ym, const weekday_last& wdl) NOEXCEPT;
146
149operator/(const year& y, const month_weekday_last& mwdl) NOEXCEPT;
150
153operator/(int y, const month_weekday_last& mwdl) NOEXCEPT;
154
157operator/(const month_weekday_last& mwdl, const year& y) NOEXCEPT;
158
161operator/(const month_weekday_last& mwdl, int y) NOEXCEPT;
162
163// Detailed interface
164
165// day
166
167class day
168{
169 unsigned char d_;
170
171public:
172 explicit CONSTCD11 day(unsigned d) NOEXCEPT;
173
175 CONSTCD14 day operator++(int) NOEXCEPT;
176 CONSTCD14 day& operator--() NOEXCEPT;
177 CONSTCD14 day operator--(int) NOEXCEPT;
178
179 CONSTCD14 day& operator+=(const days& d) NOEXCEPT;
180 CONSTCD14 day& operator-=(const days& d) NOEXCEPT;
181
182 CONSTCD11 explicit operator unsigned() const NOEXCEPT;
183 CONSTCD11 bool ok() const NOEXCEPT;
184};
185
186CONSTCD11 bool operator==(const day& x, const day& y) NOEXCEPT;
187CONSTCD11 bool operator!=(const day& x, const day& y) NOEXCEPT;
188CONSTCD11 bool operator< (const day& x, const day& y) NOEXCEPT;
189CONSTCD11 bool operator> (const day& x, const day& y) NOEXCEPT;
190CONSTCD11 bool operator<=(const day& x, const day& y) NOEXCEPT;
191CONSTCD11 bool operator>=(const day& x, const day& y) NOEXCEPT;
192
193CONSTCD11 day operator+(const day& x, const days& y) NOEXCEPT;
194CONSTCD11 day operator+(const days& x, const day& y) NOEXCEPT;
195CONSTCD11 day operator-(const day& x, const days& y) NOEXCEPT;
196CONSTCD11 days operator-(const day& x, const day& y) NOEXCEPT;
197
198template<class CharT, class Traits>
199std::basic_ostream<CharT, Traits>&
200operator<<(std::basic_ostream<CharT, Traits>& os, const day& d);
201
202// month
203
204class month
205{
206 unsigned char m_;
207
208public:
209 explicit CONSTCD11 month(unsigned m) NOEXCEPT;
210
212 CONSTCD14 month operator++(int) NOEXCEPT;
213 CONSTCD14 month& operator--() NOEXCEPT;
214 CONSTCD14 month operator--(int) NOEXCEPT;
215
216 CONSTCD14 month& operator+=(const months& m) NOEXCEPT;
217 CONSTCD14 month& operator-=(const months& m) NOEXCEPT;
218
219 CONSTCD11 explicit operator unsigned() const NOEXCEPT;
220 CONSTCD11 bool ok() const NOEXCEPT;
221};
222
223CONSTCD11 bool operator==(const month& x, const month& y) NOEXCEPT;
224CONSTCD11 bool operator!=(const month& x, const month& y) NOEXCEPT;
225CONSTCD11 bool operator< (const month& x, const month& y) NOEXCEPT;
226CONSTCD11 bool operator> (const month& x, const month& y) NOEXCEPT;
227CONSTCD11 bool operator<=(const month& x, const month& y) NOEXCEPT;
228CONSTCD11 bool operator>=(const month& x, const month& y) NOEXCEPT;
229
230CONSTCD14 month operator+(const month& x, const months& y) NOEXCEPT;
231CONSTCD14 month operator+(const months& x, const month& y) NOEXCEPT;
232CONSTCD14 month operator-(const month& x, const months& y) NOEXCEPT;
233CONSTCD14 months operator-(const month& x, const month& y) NOEXCEPT;
234
235template<class CharT, class Traits>
236std::basic_ostream<CharT, Traits>&
237operator<<(std::basic_ostream<CharT, Traits>& os, const month& m);
238
239// year
240
241class year
242{
243 short y_;
244
245public:
246 explicit CONSTCD11 year(int y) NOEXCEPT;
247
249 CONSTCD14 year operator++(int) NOEXCEPT;
250 CONSTCD14 year& operator--() NOEXCEPT;
251 CONSTCD14 year operator--(int) NOEXCEPT;
252
253 CONSTCD14 year& operator+=(const years& y) NOEXCEPT;
254 CONSTCD14 year& operator-=(const years& y) NOEXCEPT;
255
256 CONSTCD11 bool is_leap() const NOEXCEPT;
257
258 CONSTCD11 explicit operator int() const NOEXCEPT;
259 CONSTCD11 bool ok() const NOEXCEPT;
260
261 static CONSTCD11 year min() NOEXCEPT;
262 static CONSTCD11 year max() NOEXCEPT;
263};
264
265CONSTCD11 bool operator==(const year& x, const year& y) NOEXCEPT;
266CONSTCD11 bool operator!=(const year& x, const year& y) NOEXCEPT;
267CONSTCD11 bool operator< (const year& x, const year& y) NOEXCEPT;
268CONSTCD11 bool operator> (const year& x, const year& y) NOEXCEPT;
269CONSTCD11 bool operator<=(const year& x, const year& y) NOEXCEPT;
270CONSTCD11 bool operator>=(const year& x, const year& y) NOEXCEPT;
271
272CONSTCD11 year operator+(const year& x, const years& y) NOEXCEPT;
273CONSTCD11 year operator+(const years& x, const year& y) NOEXCEPT;
274CONSTCD11 year operator-(const year& x, const years& y) NOEXCEPT;
275CONSTCD11 years operator-(const year& x, const year& y) NOEXCEPT;
276
277template<class CharT, class Traits>
278std::basic_ostream<CharT, Traits>&
279operator<<(std::basic_ostream<CharT, Traits>& os, const year& y);
280
281// weekday
282
284{
285 unsigned char wd_;
286public:
287 explicit CONSTCD11 weekday(unsigned wd) NOEXCEPT;
288 explicit weekday(int) = delete;
290 CONSTCD11 explicit weekday(const local_days& dp) NOEXCEPT;
291
293 CONSTCD14 weekday operator++(int) NOEXCEPT;
294 CONSTCD14 weekday& operator--() NOEXCEPT;
295 CONSTCD14 weekday operator--(int) NOEXCEPT;
296
297 CONSTCD14 weekday& operator+=(const days& d) NOEXCEPT;
298 CONSTCD14 weekday& operator-=(const days& d) NOEXCEPT;
299
300 CONSTCD11 explicit operator unsigned() const NOEXCEPT;
301 CONSTCD11 bool ok() const NOEXCEPT;
302
303 CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT;
304 CONSTCD11 weekday_last operator[](last_spec) const NOEXCEPT;
305
306private:
307 static CONSTCD11 unsigned char weekday_from_days(int z) NOEXCEPT;
308};
309
310CONSTCD11 bool operator==(const weekday& x, const weekday& y) NOEXCEPT;
311CONSTCD11 bool operator!=(const weekday& x, const weekday& y) NOEXCEPT;
312
313CONSTCD14 weekday operator+(const weekday& x, const days& y) NOEXCEPT;
314CONSTCD14 weekday operator+(const days& x, const weekday& y) NOEXCEPT;
315CONSTCD14 weekday operator-(const weekday& x, const days& y) NOEXCEPT;
316CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT;
317
318template<class CharT, class Traits>
319std::basic_ostream<CharT, Traits>&
320operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd);
321
322// weekday_indexed
323
325{
326 unsigned char wd_ : 4;
327 unsigned char index_ : 4;
328
329public:
330 CONSTCD11 weekday_indexed(const julian::weekday& wd, unsigned index) NOEXCEPT;
331
333 CONSTCD11 unsigned index() const NOEXCEPT;
334 CONSTCD11 bool ok() const NOEXCEPT;
335};
336
337CONSTCD11 bool operator==(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT;
338CONSTCD11 bool operator!=(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT;
339
340template<class CharT, class Traits>
341std::basic_ostream<CharT, Traits>&
342operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi);
343
344// weekday_last
345
347{
349
350public:
352
354 CONSTCD11 bool ok() const NOEXCEPT;
355};
356
357CONSTCD11 bool operator==(const weekday_last& x, const weekday_last& y) NOEXCEPT;
358CONSTCD11 bool operator!=(const weekday_last& x, const weekday_last& y) NOEXCEPT;
359
360template<class CharT, class Traits>
361std::basic_ostream<CharT, Traits>&
362operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_last& wdl);
363
364// year_month
365
367{
370
371public:
373
376
377 CONSTCD14 year_month& operator+=(const months& dm) NOEXCEPT;
378 CONSTCD14 year_month& operator-=(const months& dm) NOEXCEPT;
379 CONSTCD14 year_month& operator+=(const years& dy) NOEXCEPT;
380 CONSTCD14 year_month& operator-=(const years& dy) NOEXCEPT;
381
382 CONSTCD11 bool ok() const NOEXCEPT;
383};
384
385CONSTCD11 bool operator==(const year_month& x, const year_month& y) NOEXCEPT;
386CONSTCD11 bool operator!=(const year_month& x, const year_month& y) NOEXCEPT;
387CONSTCD11 bool operator< (const year_month& x, const year_month& y) NOEXCEPT;
388CONSTCD11 bool operator> (const year_month& x, const year_month& y) NOEXCEPT;
389CONSTCD11 bool operator<=(const year_month& x, const year_month& y) NOEXCEPT;
390CONSTCD11 bool operator>=(const year_month& x, const year_month& y) NOEXCEPT;
391
392CONSTCD14 year_month operator+(const year_month& ym, const months& dm) NOEXCEPT;
393CONSTCD14 year_month operator+(const months& dm, const year_month& ym) NOEXCEPT;
394CONSTCD14 year_month operator-(const year_month& ym, const months& dm) NOEXCEPT;
395
396CONSTCD11 months operator-(const year_month& x, const year_month& y) NOEXCEPT;
397CONSTCD11 year_month operator+(const year_month& ym, const years& dy) NOEXCEPT;
398CONSTCD11 year_month operator+(const years& dy, const year_month& ym) NOEXCEPT;
399CONSTCD11 year_month operator-(const year_month& ym, const years& dy) NOEXCEPT;
400
401template<class CharT, class Traits>
402std::basic_ostream<CharT, Traits>&
403operator<<(std::basic_ostream<CharT, Traits>& os, const year_month& ym);
404
405// month_day
406
408{
411
412public:
414
417
418 CONSTCD14 bool ok() const NOEXCEPT;
419};
420
421CONSTCD11 bool operator==(const month_day& x, const month_day& y) NOEXCEPT;
422CONSTCD11 bool operator!=(const month_day& x, const month_day& y) NOEXCEPT;
423CONSTCD11 bool operator< (const month_day& x, const month_day& y) NOEXCEPT;
424CONSTCD11 bool operator> (const month_day& x, const month_day& y) NOEXCEPT;
425CONSTCD11 bool operator<=(const month_day& x, const month_day& y) NOEXCEPT;
426CONSTCD11 bool operator>=(const month_day& x, const month_day& y) NOEXCEPT;
427
428template<class CharT, class Traits>
429std::basic_ostream<CharT, Traits>&
430operator<<(std::basic_ostream<CharT, Traits>& os, const month_day& md);
431
432// month_day_last
433
435{
437
438public:
440
442 CONSTCD11 bool ok() const NOEXCEPT;
443};
444
445CONSTCD11 bool operator==(const month_day_last& x, const month_day_last& y) NOEXCEPT;
446CONSTCD11 bool operator!=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
447CONSTCD11 bool operator< (const month_day_last& x, const month_day_last& y) NOEXCEPT;
448CONSTCD11 bool operator> (const month_day_last& x, const month_day_last& y) NOEXCEPT;
449CONSTCD11 bool operator<=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
450CONSTCD11 bool operator>=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
451
452template<class CharT, class Traits>
453std::basic_ostream<CharT, Traits>&
454operator<<(std::basic_ostream<CharT, Traits>& os, const month_day_last& mdl);
455
456// month_weekday
457
459{
462public:
465
468
469 CONSTCD11 bool ok() const NOEXCEPT;
470};
471
472CONSTCD11 bool operator==(const month_weekday& x, const month_weekday& y) NOEXCEPT;
473CONSTCD11 bool operator!=(const month_weekday& x, const month_weekday& y) NOEXCEPT;
474
475template<class CharT, class Traits>
476std::basic_ostream<CharT, Traits>&
477operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday& mwd);
478
479// month_weekday_last
480
482{
485
486public:
489
492
493 CONSTCD11 bool ok() const NOEXCEPT;
494};
495
497 bool operator==(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT;
499 bool operator!=(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT;
500
501template<class CharT, class Traits>
502std::basic_ostream<CharT, Traits>&
503operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl);
504
505// class year_month_day
506
508{
512
513public:
515 const julian::day& d) NOEXCEPT;
517
520
525
529
530 CONSTCD14 operator sys_days() const NOEXCEPT;
531 CONSTCD14 explicit operator local_days() const NOEXCEPT;
532 CONSTCD14 bool ok() const NOEXCEPT;
533
534private:
535 static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT;
536 CONSTCD14 days to_days() const NOEXCEPT;
537};
538
539CONSTCD11 bool operator==(const year_month_day& x, const year_month_day& y) NOEXCEPT;
540CONSTCD11 bool operator!=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
541CONSTCD11 bool operator< (const year_month_day& x, const year_month_day& y) NOEXCEPT;
542CONSTCD11 bool operator> (const year_month_day& x, const year_month_day& y) NOEXCEPT;
543CONSTCD11 bool operator<=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
544CONSTCD11 bool operator>=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
545
546CONSTCD14 year_month_day operator+(const year_month_day& ymd, const months& dm) NOEXCEPT;
547CONSTCD14 year_month_day operator+(const months& dm, const year_month_day& ymd) NOEXCEPT;
548CONSTCD14 year_month_day operator-(const year_month_day& ymd, const months& dm) NOEXCEPT;
549CONSTCD11 year_month_day operator+(const year_month_day& ymd, const years& dy) NOEXCEPT;
550CONSTCD11 year_month_day operator+(const years& dy, const year_month_day& ymd) NOEXCEPT;
551CONSTCD11 year_month_day operator-(const year_month_day& ymd, const years& dy) NOEXCEPT;
552
553template<class CharT, class Traits>
554std::basic_ostream<CharT, Traits>&
555operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day& ymd);
556
557// year_month_day_last
558
560{
563
564public:
567
572
577
578 CONSTCD14 operator sys_days() const NOEXCEPT;
579 CONSTCD14 explicit operator local_days() const NOEXCEPT;
580 CONSTCD11 bool ok() const NOEXCEPT;
581};
582
584 bool operator==(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
586 bool operator!=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
588 bool operator< (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
590 bool operator> (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
592 bool operator<=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
594 bool operator>=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
595
598operator+(const year_month_day_last& ymdl, const months& dm) NOEXCEPT;
599
602operator+(const months& dm, const year_month_day_last& ymdl) NOEXCEPT;
603
606operator+(const year_month_day_last& ymdl, const years& dy) NOEXCEPT;
607
610operator+(const years& dy, const year_month_day_last& ymdl) NOEXCEPT;
611
614operator-(const year_month_day_last& ymdl, const months& dm) NOEXCEPT;
615
618operator-(const year_month_day_last& ymdl, const years& dy) NOEXCEPT;
619
620template<class CharT, class Traits>
621std::basic_ostream<CharT, Traits>&
622operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl);
623
624// year_month_weekday
625
627{
631
632public:
637
642
646 CONSTCD11 unsigned index() const NOEXCEPT;
648
649 CONSTCD14 operator sys_days() const NOEXCEPT;
650 CONSTCD14 explicit operator local_days() const NOEXCEPT;
651 CONSTCD14 bool ok() const NOEXCEPT;
652
653private:
654 static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT;
655 CONSTCD14 days to_days() const NOEXCEPT;
656};
657
659 bool operator==(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT;
661 bool operator!=(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT;
662
665operator+(const year_month_weekday& ymwd, const months& dm) NOEXCEPT;
666
669operator+(const months& dm, const year_month_weekday& ymwd) NOEXCEPT;
670
673operator+(const year_month_weekday& ymwd, const years& dy) NOEXCEPT;
674
677operator+(const years& dy, const year_month_weekday& ymwd) NOEXCEPT;
678
681operator-(const year_month_weekday& ymwd, const months& dm) NOEXCEPT;
682
685operator-(const year_month_weekday& ymwd, const years& dy) NOEXCEPT;
686
687template<class CharT, class Traits>
688std::basic_ostream<CharT, Traits>&
689operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwdi);
690
691// year_month_weekday_last
692
694{
698
699public:
701 const julian::weekday_last& wdl) NOEXCEPT;
702
707
712
713 CONSTCD14 operator sys_days() const NOEXCEPT;
714 CONSTCD14 explicit operator local_days() const NOEXCEPT;
715 CONSTCD11 bool ok() const NOEXCEPT;
716
717private:
718 CONSTCD14 days to_days() const NOEXCEPT;
719};
720
722bool
723operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT;
724
726bool
727operator!=(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT;
728
731operator+(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT;
732
735operator+(const months& dm, const year_month_weekday_last& ymwdl) NOEXCEPT;
736
739operator+(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT;
740
743operator+(const years& dy, const year_month_weekday_last& ymwdl) NOEXCEPT;
744
747operator-(const year_month_weekday_last& ymwdl, const months& dm) NOEXCEPT;
748
751operator-(const year_month_weekday_last& ymwdl, const years& dy) NOEXCEPT;
752
753template<class CharT, class Traits>
754std::basic_ostream<CharT, Traits>&
755operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl);
756
757#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
758inline namespace literals
759{
760
761CONSTCD11 julian::day operator "" _d(unsigned long long d) NOEXCEPT;
762CONSTCD11 julian::year operator "" _y(unsigned long long y) NOEXCEPT;
763
764// CONSTDATA julian::month jan{1};
765// CONSTDATA julian::month feb{2};
766// CONSTDATA julian::month mar{3};
767// CONSTDATA julian::month apr{4};
768// CONSTDATA julian::month may{5};
769// CONSTDATA julian::month jun{6};
770// CONSTDATA julian::month jul{7};
771// CONSTDATA julian::month aug{8};
772// CONSTDATA julian::month sep{9};
773// CONSTDATA julian::month oct{10};
774// CONSTDATA julian::month nov{11};
775// CONSTDATA julian::month dec{12};
776
777} // inline namespace literals
778#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
779
780//----------------+
781// Implementation |
782//----------------+
783
784// day
785
786CONSTCD11 inline day::day(unsigned d) NOEXCEPT : d_(static_cast<unsigned char>(d)) {}
787CONSTCD14 inline day& day::operator++() NOEXCEPT {++d_; return *this;}
788CONSTCD14 inline day day::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
789CONSTCD14 inline day& day::operator--() NOEXCEPT {--d_; return *this;}
790CONSTCD14 inline day day::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
791CONSTCD14 inline day& day::operator+=(const days& d) NOEXCEPT {*this = *this + d; return *this;}
792CONSTCD14 inline day& day::operator-=(const days& d) NOEXCEPT {*this = *this - d; return *this;}
793CONSTCD11 inline day::operator unsigned() const NOEXCEPT {return d_;}
794CONSTCD11 inline bool day::ok() const NOEXCEPT {return 1 <= d_ && d_ <= 31;}
795
797inline
798bool
799operator==(const day& x, const day& y) NOEXCEPT
800{
801 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
802}
803
805inline
806bool
807operator!=(const day& x, const day& y) NOEXCEPT
808{
809 return !(x == y);
810}
811
813inline
814bool
815operator<(const day& x, const day& y) NOEXCEPT
816{
817 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
818}
819
821inline
822bool
823operator>(const day& x, const day& y) NOEXCEPT
824{
825 return y < x;
826}
827
829inline
830bool
831operator<=(const day& x, const day& y) NOEXCEPT
832{
833 return !(y < x);
834}
835
837inline
838bool
839operator>=(const day& x, const day& y) NOEXCEPT
840{
841 return !(x < y);
842}
843
845inline
846days
847operator-(const day& x, const day& y) NOEXCEPT
848{
849 return days{static_cast<days::rep>(static_cast<unsigned>(x)
850 - static_cast<unsigned>(y))};
851}
852
854inline
855day
856operator+(const day& x, const days& y) NOEXCEPT
857{
858 return day{static_cast<unsigned>(x) + static_cast<unsigned>(y.count())};
859}
860
862inline
863day
864operator+(const days& x, const day& y) NOEXCEPT
865{
866 return y + x;
867}
868
870inline
871day
872operator-(const day& x, const days& y) NOEXCEPT
873{
874 return x + -y;
875}
876
877template<class CharT, class Traits>
878inline
879std::basic_ostream<CharT, Traits>&
880operator<<(std::basic_ostream<CharT, Traits>& os, const day& d)
881{
883 os.fill('0');
884 os.flags(std::ios::dec | std::ios::right);
885 os.width(2);
886 os << static_cast<unsigned>(d);
887 return os;
888}
889
890// month
891
892CONSTCD11 inline month::month(unsigned m) NOEXCEPT : m_(static_cast<decltype(m_)>(m)) {}
893CONSTCD14 inline month& month::operator++() NOEXCEPT {if (++m_ == 13) m_ = 1; return *this;}
894CONSTCD14 inline month month::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
895CONSTCD14 inline month& month::operator--() NOEXCEPT {if (--m_ == 0) m_ = 12; return *this;}
896CONSTCD14 inline month month::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
897
899inline
900month&
902{
903 *this = *this + m;
904 return *this;
905}
906
908inline
909month&
911{
912 *this = *this - m;
913 return *this;
914}
915
916CONSTCD11 inline month::operator unsigned() const NOEXCEPT {return m_;}
917CONSTCD11 inline bool month::ok() const NOEXCEPT {return 1 <= m_ && m_ <= 12;}
918
920inline
921bool
922operator==(const month& x, const month& y) NOEXCEPT
923{
924 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
925}
926
928inline
929bool
930operator!=(const month& x, const month& y) NOEXCEPT
931{
932 return !(x == y);
933}
934
936inline
937bool
938operator<(const month& x, const month& y) NOEXCEPT
939{
940 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
941}
942
944inline
945bool
946operator>(const month& x, const month& y) NOEXCEPT
947{
948 return y < x;
949}
950
952inline
953bool
954operator<=(const month& x, const month& y) NOEXCEPT
955{
956 return !(y < x);
957}
958
960inline
961bool
962operator>=(const month& x, const month& y) NOEXCEPT
963{
964 return !(x < y);
965}
966
968inline
969months
970operator-(const month& x, const month& y) NOEXCEPT
971{
972 auto const d = static_cast<unsigned>(x) - static_cast<unsigned>(y);
973 return months(d <= 11 ? d : d + 12);
974}
975
977inline
978month
979operator+(const month& x, const months& y) NOEXCEPT
980{
981 auto const mu = static_cast<long long>(static_cast<unsigned>(x)) - 1 + y.count();
982 auto const yr = (mu >= 0 ? mu : mu-11) / 12;
983 return month{static_cast<unsigned>(mu - yr * 12 + 1)};
984}
985
987inline
988month
989operator+(const months& x, const month& y) NOEXCEPT
990{
991 return y + x;
992}
993
995inline
996month
997operator-(const month& x, const months& y) NOEXCEPT
998{
999 return x + -y;
1000}
1001
1002template<class CharT, class Traits>
1003inline
1004std::basic_ostream<CharT, Traits>&
1005operator<<(std::basic_ostream<CharT, Traits>& os, const month& m)
1006{
1007 switch (static_cast<unsigned>(m))
1008 {
1009 case 1:
1010 os << "Jan";
1011 break;
1012 case 2:
1013 os << "Feb";
1014 break;
1015 case 3:
1016 os << "Mar";
1017 break;
1018 case 4:
1019 os << "Apr";
1020 break;
1021 case 5:
1022 os << "May";
1023 break;
1024 case 6:
1025 os << "Jun";
1026 break;
1027 case 7:
1028 os << "Jul";
1029 break;
1030 case 8:
1031 os << "Aug";
1032 break;
1033 case 9:
1034 os << "Sep";
1035 break;
1036 case 10:
1037 os << "Oct";
1038 break;
1039 case 11:
1040 os << "Nov";
1041 break;
1042 case 12:
1043 os << "Dec";
1044 break;
1045 default:
1046 os << static_cast<unsigned>(m) << " is not a valid month";
1047 break;
1048 }
1049 return os;
1050}
1051
1052// year
1053
1054CONSTCD11 inline year::year(int y) NOEXCEPT : y_(static_cast<decltype(y_)>(y)) {}
1055CONSTCD14 inline year& year::operator++() NOEXCEPT {++y_; return *this;}
1056CONSTCD14 inline year year::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
1057CONSTCD14 inline year& year::operator--() NOEXCEPT {--y_; return *this;}
1058CONSTCD14 inline year year::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
1059CONSTCD14 inline year& year::operator+=(const years& y) NOEXCEPT {*this = *this + y; return *this;}
1060CONSTCD14 inline year& year::operator-=(const years& y) NOEXCEPT {*this = *this - y; return *this;}
1061
1063inline
1064bool
1066{
1067 return y_ % 4 == 0;
1068}
1069
1070CONSTCD11 inline year::operator int() const NOEXCEPT {return y_;}
1071CONSTCD11 inline bool year::ok() const NOEXCEPT {return true;}
1072
1074inline
1075year
1077{
1079}
1080
1082inline
1083year
1085{
1087}
1088
1090inline
1091bool
1092operator==(const year& x, const year& y) NOEXCEPT
1093{
1094 return static_cast<int>(x) == static_cast<int>(y);
1095}
1096
1098inline
1099bool
1100operator!=(const year& x, const year& y) NOEXCEPT
1101{
1102 return !(x == y);
1103}
1104
1106inline
1107bool
1108operator<(const year& x, const year& y) NOEXCEPT
1109{
1110 return static_cast<int>(x) < static_cast<int>(y);
1111}
1112
1114inline
1115bool
1116operator>(const year& x, const year& y) NOEXCEPT
1117{
1118 return y < x;
1119}
1120
1122inline
1123bool
1124operator<=(const year& x, const year& y) NOEXCEPT
1125{
1126 return !(y < x);
1127}
1128
1130inline
1131bool
1132operator>=(const year& x, const year& y) NOEXCEPT
1133{
1134 return !(x < y);
1135}
1136
1138inline
1139years
1140operator-(const year& x, const year& y) NOEXCEPT
1141{
1142 return years{static_cast<int>(x) - static_cast<int>(y)};
1143}
1144
1146inline
1147year
1148operator+(const year& x, const years& y) NOEXCEPT
1149{
1150 return year{static_cast<int>(x) + y.count()};
1151}
1152
1154inline
1155year
1156operator+(const years& x, const year& y) NOEXCEPT
1157{
1158 return y + x;
1159}
1160
1162inline
1163year
1164operator-(const year& x, const years& y) NOEXCEPT
1165{
1166 return year{static_cast<int>(x) - y.count()};
1167}
1168
1169template<class CharT, class Traits>
1170inline
1171std::basic_ostream<CharT, Traits>&
1172operator<<(std::basic_ostream<CharT, Traits>& os, const year& y)
1173{
1175 os.fill('0');
1176 os.flags(std::ios::dec | std::ios::internal);
1177 os.width(4 + (y < year{0}));
1178 os << static_cast<int>(y);
1179 return os;
1180}
1181
1182// weekday
1183
1185inline
1186unsigned char
1188{
1189 return static_cast<unsigned char>(static_cast<unsigned>(
1190 z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6));
1191}
1192
1194inline
1196 : wd_(static_cast<decltype(wd_)>(wd))
1197 {}
1198
1200inline
1202 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1203 {}
1204
1206inline
1208 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1209 {}
1210
1211CONSTCD14 inline weekday& weekday::operator++() NOEXCEPT {if (++wd_ == 7) wd_ = 0; return *this;}
1212CONSTCD14 inline weekday weekday::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
1213CONSTCD14 inline weekday& weekday::operator--() NOEXCEPT {if (wd_-- == 0) wd_ = 6; return *this;}
1214CONSTCD14 inline weekday weekday::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
1215
1217inline
1218weekday&
1220{
1221 *this = *this + d;
1222 return *this;
1223}
1224
1226inline
1227weekday&
1229{
1230 *this = *this - d;
1231 return *this;
1232}
1233
1235inline
1236weekday::operator unsigned() const NOEXCEPT
1237{
1238 return static_cast<unsigned>(wd_);
1239}
1240
1241CONSTCD11 inline bool weekday::ok() const NOEXCEPT {return wd_ <= 6;}
1242
1244inline
1245bool
1247{
1248 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
1249}
1250
1252inline
1253bool
1255{
1256 return !(x == y);
1257}
1258
1260inline
1261days
1263{
1264 auto const diff = static_cast<unsigned>(x) - static_cast<unsigned>(y);
1265 return days{diff <= 6 ? diff : diff + 7};
1266}
1267
1269inline
1270weekday
1271operator+(const weekday& x, const days& y) NOEXCEPT
1272{
1273 auto const wdu = static_cast<long long>(static_cast<unsigned>(x)) + y.count();
1274 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1275 return weekday{static_cast<unsigned>(wdu - wk * 7)};
1276}
1277
1279inline
1280weekday
1281operator+(const days& x, const weekday& y) NOEXCEPT
1282{
1283 return y + x;
1284}
1285
1287inline
1288weekday
1289operator-(const weekday& x, const days& y) NOEXCEPT
1290{
1291 return x + -y;
1292}
1293
1294template<class CharT, class Traits>
1295inline
1296std::basic_ostream<CharT, Traits>&
1297operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd)
1298{
1299 switch (static_cast<unsigned>(wd))
1300 {
1301 case 0:
1302 os << "Sun";
1303 break;
1304 case 1:
1305 os << "Mon";
1306 break;
1307 case 2:
1308 os << "Tue";
1309 break;
1310 case 3:
1311 os << "Wed";
1312 break;
1313 case 4:
1314 os << "Thu";
1315 break;
1316 case 5:
1317 os << "Fri";
1318 break;
1319 case 6:
1320 os << "Sat";
1321 break;
1322 default:
1323 os << static_cast<unsigned>(wd) << " is not a valid weekday";
1324 break;
1325 }
1326 return os;
1327}
1328
1329#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1330inline namespace literals
1331{
1332
1334inline
1336operator "" _d(unsigned long long d) NOEXCEPT
1337{
1338 return julian::day{static_cast<unsigned>(d)};
1339}
1340
1342inline
1344operator "" _y(unsigned long long y) NOEXCEPT
1345{
1346 return julian::year(static_cast<int>(y));
1347}
1348#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
1349
1351
1364
1372
1373#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1374} // inline namespace literals
1375#endif
1376
1377// weekday_indexed
1378
1380inline
1381weekday
1383{
1384 return julian::weekday{static_cast<unsigned>(wd_)};
1385}
1386
1387CONSTCD11 inline unsigned weekday_indexed::index() const NOEXCEPT {return index_;}
1388
1390inline
1391bool
1393{
1394 return weekday().ok() && 1 <= index_ && index_ <= 5;
1395}
1396
1398inline
1400 : wd_(static_cast<decltype(wd_)>(static_cast<unsigned>(wd)))
1401 , index_(static_cast<decltype(index_)>(index))
1402 {}
1403
1404template<class CharT, class Traits>
1405inline
1406std::basic_ostream<CharT, Traits>&
1407operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi)
1408{
1409 return os << wdi.weekday() << '[' << wdi.index() << ']';
1410}
1411
1413inline
1414weekday_indexed
1415weekday::operator[](unsigned index) const NOEXCEPT
1416{
1417 return {*this, index};
1418}
1419
1421inline
1422bool
1424{
1425 return x.weekday() == y.weekday() && x.index() == y.index();
1426}
1427
1429inline
1430bool
1432{
1433 return !(x == y);
1434}
1435
1436// weekday_last
1437
1439CONSTCD11 inline bool weekday_last::ok() const NOEXCEPT {return wd_.ok();}
1441
1443inline
1444bool
1446{
1447 return x.weekday() == y.weekday();
1448}
1449
1451inline
1452bool
1454{
1455 return !(x == y);
1456}
1457
1458template<class CharT, class Traits>
1459inline
1460std::basic_ostream<CharT, Traits>&
1461operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_last& wdl)
1462{
1463 return os << wdl.weekday() << "[last]";
1464}
1465
1467inline
1468weekday_last
1470{
1471 return weekday_last{*this};
1472}
1473
1474// year_month
1475
1477inline
1479 : y_(y)
1480 , m_(m)
1481 {}
1482
1483CONSTCD11 inline year year_month::year() const NOEXCEPT {return y_;}
1484CONSTCD11 inline month year_month::month() const NOEXCEPT {return m_;}
1485CONSTCD11 inline bool year_month::ok() const NOEXCEPT {return y_.ok() && m_.ok();}
1486
1488inline
1491{
1492 *this = *this + dm;
1493 return *this;
1494}
1495
1497inline
1500{
1501 *this = *this - dm;
1502 return *this;
1503}
1504
1506inline
1509{
1510 *this = *this + dy;
1511 return *this;
1512}
1513
1515inline
1518{
1519 *this = *this - dy;
1520 return *this;
1521}
1522
1524inline
1525bool
1527{
1528 return x.year() == y.year() && x.month() == y.month();
1529}
1530
1532inline
1533bool
1535{
1536 return !(x == y);
1537}
1538
1540inline
1541bool
1542operator<(const year_month& x, const year_month& y) NOEXCEPT
1543{
1544 return x.year() < y.year() ? true
1545 : (x.year() > y.year() ? false
1546 : (x.month() < y.month()));
1547}
1548
1550inline
1551bool
1553{
1554 return y < x;
1555}
1556
1558inline
1559bool
1560operator<=(const year_month& x, const year_month& y) NOEXCEPT
1561{
1562 return !(y < x);
1563}
1564
1566inline
1567bool
1569{
1570 return !(x < y);
1571}
1572
1574inline
1575year_month
1577{
1578 auto dmi = static_cast<int>(static_cast<unsigned>(ym.month())) - 1 + dm.count();
1579 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
1580 dmi = dmi - dy * 12 + 1;
1581 return (ym.year() + years(dy)) / month(static_cast<unsigned>(dmi));
1582}
1583
1585inline
1586year_month
1588{
1589 return ym + dm;
1590}
1591
1593inline
1594year_month
1596{
1597 return ym + -dm;
1598}
1599
1601inline
1602months
1604{
1605 return (x.year() - y.year()) +
1606 months(static_cast<unsigned>(x.month()) - static_cast<unsigned>(y.month()));
1607}
1608
1610inline
1611year_month
1612operator+(const year_month& ym, const years& dy) NOEXCEPT
1613{
1614 return (ym.year() + dy) / ym.month();
1615}
1616
1618inline
1619year_month
1620operator+(const years& dy, const year_month& ym) NOEXCEPT
1621{
1622 return ym + dy;
1623}
1624
1626inline
1627year_month
1628operator-(const year_month& ym, const years& dy) NOEXCEPT
1629{
1630 return ym + -dy;
1631}
1632
1633template<class CharT, class Traits>
1634inline
1635std::basic_ostream<CharT, Traits>&
1636operator<<(std::basic_ostream<CharT, Traits>& os, const year_month& ym)
1637{
1638 return os << ym.year() << '/' << ym.month();
1639}
1640
1641// month_day
1642
1644inline
1646 : m_(m)
1647 , d_(d)
1648 {}
1649
1652
1654inline
1655bool
1657{
1658 CONSTDATA julian::day d[] = {
1662 };
1663 return m_.ok() && julian::day(1) <= d_ && d_ <= d[static_cast<unsigned>(m_)-1];
1664}
1665
1667inline
1668bool
1670{
1671 return x.month() == y.month() && x.day() == y.day();
1672}
1673
1675inline
1676bool
1678{
1679 return !(x == y);
1680}
1681
1683inline
1684bool
1685operator<(const month_day& x, const month_day& y) NOEXCEPT
1686{
1687 return x.month() < y.month() ? true
1688 : (x.month() > y.month() ? false
1689 : (x.day() < y.day()));
1690}
1691
1693inline
1694bool
1696{
1697 return y < x;
1698}
1699
1701inline
1702bool
1703operator<=(const month_day& x, const month_day& y) NOEXCEPT
1704{
1705 return !(y < x);
1706}
1707
1709inline
1710bool
1712{
1713 return !(x < y);
1714}
1715
1716template<class CharT, class Traits>
1717inline
1718std::basic_ostream<CharT, Traits>&
1719operator<<(std::basic_ostream<CharT, Traits>& os, const month_day& md)
1720{
1721 return os << md.month() << '/' << md.day();
1722}
1723
1724// month_day_last
1725
1727CONSTCD11 inline bool month_day_last::ok() const NOEXCEPT {return m_.ok();}
1729
1731inline
1732bool
1734{
1735 return x.month() == y.month();
1736}
1737
1739inline
1740bool
1742{
1743 return !(x == y);
1744}
1745
1747inline
1748bool
1750{
1751 return x.month() < y.month();
1752}
1753
1755inline
1756bool
1758{
1759 return y < x;
1760}
1761
1763inline
1764bool
1766{
1767 return !(y < x);
1768}
1769
1771inline
1772bool
1774{
1775 return !(x < y);
1776}
1777
1778template<class CharT, class Traits>
1779inline
1780std::basic_ostream<CharT, Traits>&
1781operator<<(std::basic_ostream<CharT, Traits>& os, const month_day_last& mdl)
1782{
1783 return os << mdl.month() << "/last";
1784}
1785
1786// month_weekday
1787
1789inline
1792 : m_(m)
1793 , wdi_(wdi)
1794 {}
1795
1797
1799inline
1802{
1803 return wdi_;
1804}
1805
1807inline
1808bool
1810{
1811 return m_.ok() && wdi_.ok();
1812}
1813
1815inline
1816bool
1818{
1819 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
1820}
1821
1823inline
1824bool
1826{
1827 return !(x == y);
1828}
1829
1830template<class CharT, class Traits>
1831inline
1832std::basic_ostream<CharT, Traits>&
1833operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday& mwd)
1834{
1835 return os << mwd.month() << '/' << mwd.weekday_indexed();
1836}
1837
1838// month_weekday_last
1839
1841inline
1843 const julian::weekday_last& wdl) NOEXCEPT
1844 : m_(m)
1845 , wdl_(wdl)
1846 {}
1847
1849
1851inline
1854{
1855 return wdl_;
1856}
1857
1859inline
1860bool
1862{
1863 return m_.ok() && wdl_.ok();
1864}
1865
1867inline
1868bool
1870{
1871 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
1872}
1873
1875inline
1876bool
1878{
1879 return !(x == y);
1880}
1881
1882template<class CharT, class Traits>
1883inline
1884std::basic_ostream<CharT, Traits>&
1885operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl)
1886{
1887 return os << mwdl.month() << '/' << mwdl.weekday_last();
1888}
1889
1890// year_month_day_last
1891
1893inline
1896 : y_(y)
1897 , mdl_(mdl)
1898 {}
1899
1901inline
1904{
1905 *this = *this + m;
1906 return *this;
1907}
1908
1910inline
1913{
1914 *this = *this - m;
1915 return *this;
1916}
1917
1919inline
1922{
1923 *this = *this + y;
1924 return *this;
1925}
1926
1928inline
1931{
1932 *this = *this - y;
1933 return *this;
1934}
1935
1938
1940inline
1943{
1944 return mdl_;
1945}
1946
1948inline
1949day
1951{
1952 CONSTDATA julian::day d[] = {
1956 };
1957 return month() != feb || !y_.is_leap() ? d[static_cast<unsigned>(month())-1] : julian::day(29);
1958}
1959
1961inline
1962year_month_day_last::operator sys_days() const NOEXCEPT
1963{
1964 return sys_days(year()/month()/day());
1965}
1966
1968inline
1969year_month_day_last::operator local_days() const NOEXCEPT
1970{
1971 return local_days(year()/month()/day());
1972}
1973
1975inline
1976bool
1978{
1979 return y_.ok() && mdl_.ok();
1980}
1981
1983inline
1984bool
1986{
1987 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
1988}
1989
1991inline
1992bool
1994{
1995 return !(x == y);
1996}
1997
1999inline
2000bool
2002{
2003 return x.year() < y.year() ? true
2004 : (x.year() > y.year() ? false
2005 : (x.month_day_last() < y.month_day_last()));
2006}
2007
2009inline
2010bool
2012{
2013 return y < x;
2014}
2015
2017inline
2018bool
2020{
2021 return !(y < x);
2022}
2023
2025inline
2026bool
2028{
2029 return !(x < y);
2030}
2031
2032template<class CharT, class Traits>
2033inline
2034std::basic_ostream<CharT, Traits>&
2035operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl)
2036{
2037 return os << ymdl.year() << '/' << ymdl.month_day_last();
2038}
2039
2041inline
2042year_month_day_last
2044{
2045 return (ymdl.year() / ymdl.month() + dm) / last;
2046}
2047
2049inline
2050year_month_day_last
2052{
2053 return ymdl + dm;
2054}
2055
2057inline
2058year_month_day_last
2060{
2061 return ymdl + (-dm);
2062}
2063
2065inline
2066year_month_day_last
2068{
2069 return {ymdl.year()+dy, ymdl.month_day_last()};
2070}
2071
2073inline
2074year_month_day_last
2076{
2077 return ymdl + dy;
2078}
2079
2081inline
2082year_month_day_last
2084{
2085 return ymdl + (-dy);
2086}
2087
2088// year_month_day
2089
2091inline
2093 const julian::day& d) NOEXCEPT
2094 : y_(y)
2095 , m_(m)
2096 , d_(d)
2097 {}
2098
2100inline
2102 : y_(ymdl.year())
2103 , m_(ymdl.month())
2104 , d_(ymdl.day())
2105 {}
2106
2108inline
2110 : year_month_day(from_days(dp.time_since_epoch()))
2111 {}
2112
2114inline
2116 : year_month_day(from_days(dp.time_since_epoch()))
2117 {}
2118
2119CONSTCD11 inline year year_month_day::year() const NOEXCEPT {return y_;}
2122
2124inline
2127{
2128 *this = *this + m;
2129 return *this;
2130}
2131
2133inline
2136{
2137 *this = *this - m;
2138 return *this;
2139}
2140
2142inline
2145{
2146 *this = *this + y;
2147 return *this;
2148}
2149
2151inline
2154{
2155 *this = *this - y;
2156 return *this;
2157}
2158
2160inline
2161days
2163{
2164 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2165 "This algorithm has not been ported to a 16 bit unsigned integer");
2166 static_assert(std::numeric_limits<int>::digits >= 20,
2167 "This algorithm has not been ported to a 16 bit signed integer");
2168 auto const y = static_cast<int>(y_) - (m_ <= feb);
2169 auto const m = static_cast<unsigned>(m_);
2170 auto const d = static_cast<unsigned>(d_);
2171 auto const era = (y >= 0 ? y : y-3) / 4;
2172 auto const yoe = static_cast<unsigned>(y - era * 4); // [0, 3]
2173 auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1; // [0, 365]
2174 auto const doe = yoe * 365 + doy; // [0, 1460]
2175 return days{era * 1461 + static_cast<int>(doe) - 719470};
2176}
2177
2179inline
2180year_month_day::operator sys_days() const NOEXCEPT
2181{
2182 return sys_days{to_days()};
2183}
2184
2186inline
2187year_month_day::operator local_days() const NOEXCEPT
2188{
2189 return local_days{to_days()};
2190}
2191
2193inline
2194bool
2196{
2197 if (!(y_.ok() && m_.ok()))
2198 return false;
2199 return julian::day(1) <= d_ && d_ <= (y_/m_/last).day();
2200}
2201
2203inline
2204bool
2206{
2207 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
2208}
2209
2211inline
2212bool
2214{
2215 return !(x == y);
2216}
2217
2219inline
2220bool
2222{
2223 return x.year() < y.year() ? true
2224 : (x.year() > y.year() ? false
2225 : (x.month() < y.month() ? true
2226 : (x.month() > y.month() ? false
2227 : (x.day() < y.day()))));
2228}
2229
2231inline
2232bool
2234{
2235 return y < x;
2236}
2237
2239inline
2240bool
2242{
2243 return !(y < x);
2244}
2245
2247inline
2248bool
2250{
2251 return !(x < y);
2252}
2253
2254template<class CharT, class Traits>
2255inline
2256std::basic_ostream<CharT, Traits>&
2257operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day& ymd)
2258{
2260 os.fill('0');
2261 os.flags(std::ios::dec | std::ios::right);
2262 os << ymd.year() << '-';
2263 os.width(2);
2264 os << static_cast<unsigned>(ymd.month()) << '-';
2265 os << ymd.day();
2266 return os;
2267}
2268
2270inline
2271year_month_day
2273{
2274 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2275 "This algorithm has not been ported to a 16 bit unsigned integer");
2276 static_assert(std::numeric_limits<int>::digits >= 20,
2277 "This algorithm has not been ported to a 16 bit signed integer");
2278 auto const z = dp.count() + 719470;
2279 auto const era = (z >= 0 ? z : z - 1460) / 1461;
2280 auto const doe = static_cast<unsigned>(z - era * 1461); // [0, 1460]
2281 auto const yoe = (doe - doe/1460) / 365; // [0, 3]
2282 auto const y = static_cast<sys_days::rep>(yoe) + era * 4;
2283 auto const doy = doe - 365*yoe; // [0, 365]
2284 auto const mp = (5*doy + 2)/153; // [0, 11]
2285 auto const d = doy - (153*mp+2)/5 + 1; // [1, 31]
2286 auto const m = mp < 10 ? mp+3 : mp-9; // [1, 12]
2287 return year_month_day{julian::year{y + (m <= 2)}, julian::month(m), julian::day(d)};
2288}
2289
2291inline
2294{
2295 return (ymd.year() / ymd.month() + dm) / ymd.day();
2296}
2297
2299inline
2300year_month_day
2302{
2303 return ymd + dm;
2304}
2305
2307inline
2308year_month_day
2310{
2311 return ymd + (-dm);
2312}
2313
2315inline
2316year_month_day
2318{
2319 return (ymd.year() + dy) / ymd.month() / ymd.day();
2320}
2321
2323inline
2324year_month_day
2326{
2327 return ymd + dy;
2328}
2329
2331inline
2332year_month_day
2334{
2335 return ymd + (-dy);
2336}
2337
2338// year_month_weekday
2339
2341inline
2343 const julian::weekday_indexed& wdi)
2344 NOEXCEPT
2345 : y_(y)
2346 , m_(m)
2347 , wdi_(wdi)
2348 {}
2349
2351inline
2353 : year_month_weekday(from_days(dp.time_since_epoch()))
2354 {}
2355
2357inline
2359 : year_month_weekday(from_days(dp.time_since_epoch()))
2360 {}
2361
2363inline
2366{
2367 *this = *this + m;
2368 return *this;
2369}
2370
2372inline
2375{
2376 *this = *this - m;
2377 return *this;
2378}
2379
2381inline
2384{
2385 *this = *this + y;
2386 return *this;
2387}
2388
2390inline
2393{
2394 *this = *this - y;
2395 return *this;
2396}
2397
2400
2402inline
2403weekday
2405{
2406 return wdi_.weekday();
2407}
2408
2410inline
2411unsigned
2413{
2414 return wdi_.index();
2415}
2416
2418inline
2421{
2422 return wdi_;
2423}
2424
2426inline
2427year_month_weekday::operator sys_days() const NOEXCEPT
2428{
2429 return sys_days{to_days()};
2430}
2431
2433inline
2434year_month_weekday::operator local_days() const NOEXCEPT
2435{
2436 return local_days{to_days()};
2437}
2438
2440inline
2441bool
2443{
2444 if (!y_.ok() || !m_.ok() || !wdi_.weekday().ok() || wdi_.index() < 1)
2445 return false;
2446 if (wdi_.index() <= 4)
2447 return true;
2448 auto d2 = wdi_.weekday() - julian::weekday(y_/m_/1) + days((wdi_.index()-1)*7 + 1);
2449 return static_cast<unsigned>(d2.count()) <= static_cast<unsigned>((y_/m_/last).day());
2450}
2451
2453inline
2456{
2457 sys_days dp{d};
2458 auto const wd = julian::weekday(dp);
2459 auto const ymd = year_month_day(dp);
2460 return {ymd.year(), ymd.month(), wd[(static_cast<unsigned>(ymd.day())-1)/7+1]};
2461}
2462
2464inline
2465days
2467{
2468 auto d = sys_days(y_/m_/1);
2469 return (d + (wdi_.weekday() - julian::weekday(d) + days{(wdi_.index()-1)*7})
2470 ).time_since_epoch();
2471}
2472
2474inline
2475bool
2477{
2478 return x.year() == y.year() && x.month() == y.month() &&
2479 x.weekday_indexed() == y.weekday_indexed();
2480}
2481
2483inline
2484bool
2486{
2487 return !(x == y);
2488}
2489
2490template<class CharT, class Traits>
2491inline
2492std::basic_ostream<CharT, Traits>&
2493operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwdi)
2494{
2495 return os << ymwdi.year() << '/' << ymwdi.month()
2496 << '/' << ymwdi.weekday_indexed();
2497}
2498
2500inline
2501year_month_weekday
2503{
2504 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
2505}
2506
2508inline
2509year_month_weekday
2511{
2512 return ymwd + dm;
2513}
2514
2516inline
2517year_month_weekday
2519{
2520 return ymwd + (-dm);
2521}
2522
2524inline
2525year_month_weekday
2527{
2528 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
2529}
2530
2532inline
2533year_month_weekday
2535{
2536 return ymwd + dy;
2537}
2538
2540inline
2541year_month_weekday
2543{
2544 return ymwd + (-dy);
2545}
2546
2547// year_month_weekday_last
2548
2550inline
2552 const julian::month& m,
2553 const julian::weekday_last& wdl) NOEXCEPT
2554 : y_(y)
2555 , m_(m)
2556 , wdl_(wdl)
2557 {}
2558
2560inline
2563{
2564 *this = *this + m;
2565 return *this;
2566}
2567
2569inline
2572{
2573 *this = *this - m;
2574 return *this;
2575}
2576
2578inline
2581{
2582 *this = *this + y;
2583 return *this;
2584}
2585
2587inline
2590{
2591 *this = *this - y;
2592 return *this;
2593}
2594
2597
2599inline
2600weekday
2602{
2603 return wdl_.weekday();
2604}
2605
2607inline
2610{
2611 return wdl_;
2612}
2613
2615inline
2616year_month_weekday_last::operator sys_days() const NOEXCEPT
2617{
2618 return sys_days{to_days()};
2619}
2620
2622inline
2623year_month_weekday_last::operator local_days() const NOEXCEPT
2624{
2625 return local_days{to_days()};
2626}
2627
2629inline
2630bool
2632{
2633 return y_.ok() && m_.ok() && wdl_.ok();
2634}
2635
2637inline
2638days
2640{
2641 auto const d = sys_days(y_/m_/last);
2642 return (d - (julian::weekday{d} - wdl_.weekday())).time_since_epoch();
2643}
2644
2646inline
2647bool
2649{
2650 return x.year() == y.year() && x.month() == y.month() &&
2651 x.weekday_last() == y.weekday_last();
2652}
2653
2655inline
2656bool
2658{
2659 return !(x == y);
2660}
2661
2662template<class CharT, class Traits>
2663inline
2664std::basic_ostream<CharT, Traits>&
2665operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl)
2666{
2667 return os << ymwdl.year() << '/' << ymwdl.month() << '/' << ymwdl.weekday_last();
2668}
2669
2671inline
2672year_month_weekday_last
2674{
2675 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
2676}
2677
2679inline
2680year_month_weekday_last
2682{
2683 return ymwdl + dm;
2684}
2685
2687inline
2688year_month_weekday_last
2690{
2691 return ymwdl + (-dm);
2692}
2693
2695inline
2696year_month_weekday_last
2698{
2699 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
2700}
2701
2703inline
2704year_month_weekday_last
2706{
2707 return ymwdl + dy;
2708}
2709
2711inline
2712year_month_weekday_last
2714{
2715 return ymwdl + (-dy);
2716}
2717
2718// year_month from operator/()
2719
2721inline
2722year_month
2723operator/(const year& y, const month& m) NOEXCEPT
2724{
2725 return {y, m};
2726}
2727
2729inline
2730year_month
2731operator/(const year& y, int m) NOEXCEPT
2732{
2733 return y / month(static_cast<unsigned>(m));
2734}
2735
2736// month_day from operator/()
2737
2739inline
2740month_day
2741operator/(const month& m, const day& d) NOEXCEPT
2742{
2743 return {m, d};
2744}
2745
2747inline
2748month_day
2749operator/(const day& d, const month& m) NOEXCEPT
2750{
2751 return m / d;
2752}
2753
2755inline
2756month_day
2757operator/(const month& m, int d) NOEXCEPT
2758{
2759 return m / day(static_cast<unsigned>(d));
2760}
2761
2763inline
2764month_day
2765operator/(int m, const day& d) NOEXCEPT
2766{
2767 return month(static_cast<unsigned>(m)) / d;
2768}
2769
2770CONSTCD11 inline month_day operator/(const day& d, int m) NOEXCEPT {return m / d;}
2771
2772// month_day_last from operator/()
2773
2775inline
2776month_day_last
2778{
2779 return month_day_last{m};
2780}
2781
2783inline
2784month_day_last
2786{
2787 return m/last;
2788}
2789
2791inline
2792month_day_last
2794{
2795 return month(static_cast<unsigned>(m))/last;
2796}
2797
2799inline
2800month_day_last
2802{
2803 return m/last;
2804}
2805
2806// month_weekday from operator/()
2807
2809inline
2810month_weekday
2812{
2813 return {m, wdi};
2814}
2815
2817inline
2818month_weekday
2820{
2821 return m / wdi;
2822}
2823
2825inline
2826month_weekday
2828{
2829 return month(static_cast<unsigned>(m)) / wdi;
2830}
2831
2833inline
2834month_weekday
2836{
2837 return m / wdi;
2838}
2839
2840// month_weekday_last from operator/()
2841
2843inline
2844month_weekday_last
2846{
2847 return {m, wdl};
2848}
2849
2851inline
2852month_weekday_last
2854{
2855 return m / wdl;
2856}
2857
2859inline
2860month_weekday_last
2862{
2863 return month(static_cast<unsigned>(m)) / wdl;
2864}
2865
2867inline
2868month_weekday_last
2870{
2871 return m / wdl;
2872}
2873
2874// year_month_day from operator/()
2875
2877inline
2878year_month_day
2879operator/(const year_month& ym, const day& d) NOEXCEPT
2880{
2881 return {ym.year(), ym.month(), d};
2882}
2883
2885inline
2886year_month_day
2888{
2889 return ym / day(static_cast<unsigned>(d));
2890}
2891
2893inline
2894year_month_day
2895operator/(const year& y, const month_day& md) NOEXCEPT
2896{
2897 return y / md.month() / md.day();
2898}
2899
2901inline
2902year_month_day
2904{
2905 return year(y) / md;
2906}
2907
2909inline
2910year_month_day
2911operator/(const month_day& md, const year& y) NOEXCEPT
2912{
2913 return y / md;
2914}
2915
2917inline
2918year_month_day
2920{
2921 return year(y) / md;
2922}
2923
2924// year_month_day_last from operator/()
2925
2927inline
2928year_month_day_last
2930{
2931 return {ym.year(), month_day_last{ym.month()}};
2932}
2933
2935inline
2936year_month_day_last
2938{
2939 return {y, mdl};
2940}
2941
2943inline
2944year_month_day_last
2946{
2947 return year(y) / mdl;
2948}
2949
2951inline
2952year_month_day_last
2954{
2955 return y / mdl;
2956}
2957
2959inline
2960year_month_day_last
2962{
2963 return year(y) / mdl;
2964}
2965
2966// year_month_weekday from operator/()
2967
2969inline
2970year_month_weekday
2972{
2973 return {ym.year(), ym.month(), wdi};
2974}
2975
2977inline
2978year_month_weekday
2980{
2981 return {y, mwd.month(), mwd.weekday_indexed()};
2982}
2983
2985inline
2986year_month_weekday
2988{
2989 return year(y) / mwd;
2990}
2991
2993inline
2994year_month_weekday
2996{
2997 return y / mwd;
2998}
2999
3001inline
3002year_month_weekday
3004{
3005 return year(y) / mwd;
3006}
3007
3008// year_month_weekday_last from operator/()
3009
3011inline
3012year_month_weekday_last
3014{
3015 return {ym.year(), ym.month(), wdl};
3016}
3017
3019inline
3020year_month_weekday_last
3022{
3023 return {y, mwdl.month(), mwdl.weekday_last()};
3024}
3025
3027inline
3028year_month_weekday_last
3030{
3031 return year(y) / mwdl;
3032}
3033
3035inline
3036year_month_weekday_last
3038{
3039 return y / mwdl;
3040}
3041
3043inline
3044year_month_weekday_last
3046{
3047 return year(y) / mwdl;
3048}
3049
3050} // namespace julian
3051
3052#endif // JULIAN_H
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:794
CONSTCD14 day & operator+=(const days &d) NOEXCEPT
Definition: julian.h:791
CONSTCD14 day & operator-=(const days &d) NOEXCEPT
Definition: julian.h:792
CONSTCD14 day & operator--() NOEXCEPT
Definition: julian.h:789
CONSTCD14 day & operator++() NOEXCEPT
Definition: julian.h:787
unsigned char d_
Definition: julian.h:169
CONSTCD11 day(unsigned d) NOEXCEPT
Definition: julian.h:786
CONSTCD11 month_day_last(const julian::month &m) NOEXCEPT
Definition: julian.h:1728
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1727
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1726
julian::month m_
Definition: julian.h:436
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1650
CONSTCD11 month_day(const julian::month &m, const julian::day &d) NOEXCEPT
Definition: julian.h:1645
CONSTCD11 julian::day day() const NOEXCEPT
Definition: julian.h:1651
CONSTCD14 bool ok() const NOEXCEPT
Definition: julian.h:1656
julian::month m_
Definition: julian.h:409
julian::day d_
Definition: julian.h:410
CONSTCD11 julian::weekday_last weekday_last() const NOEXCEPT
Definition: julian.h:1853
julian::month m_
Definition: julian.h:483
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1861
julian::weekday_last wdl_
Definition: julian.h:484
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1848
CONSTCD11 month_weekday_last(const julian::month &m, const julian::weekday_last &wd) NOEXCEPT
Definition: julian.h:1842
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1809
julian::month m_
Definition: julian.h:460
julian::weekday_indexed wdi_
Definition: julian.h:461
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1796
CONSTCD11 month_weekday(const julian::month &m, const julian::weekday_indexed &wdi) NOEXCEPT
Definition: julian.h:1790
CONSTCD11 julian::weekday_indexed weekday_indexed() const NOEXCEPT
Definition: julian.h:1801
unsigned char m_
Definition: julian.h:206
CONSTCD14 month & operator+=(const months &m) NOEXCEPT
Definition: julian.h:901
CONSTCD14 month & operator-=(const months &m) NOEXCEPT
Definition: julian.h:910
CONSTCD14 month & operator++() NOEXCEPT
Definition: julian.h:893
CONSTCD11 month(unsigned m) NOEXCEPT
Definition: julian.h:892
CONSTCD14 month & operator--() NOEXCEPT
Definition: julian.h:895
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:917
CONSTCD11 unsigned index() const NOEXCEPT
Definition: julian.h:1387
CONSTCD11 weekday_indexed(const julian::weekday &wd, unsigned index) NOEXCEPT
Definition: julian.h:1399
unsigned char index_
Definition: julian.h:327
unsigned char wd_
Definition: julian.h:326
CONSTCD11 julian::weekday weekday() const NOEXCEPT
Definition: julian.h:1382
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1392
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1439
julian::weekday wd_
Definition: julian.h:348
CONSTCD11 julian::weekday weekday() const NOEXCEPT
Definition: julian.h:1438
CONSTCD11 weekday_last(const julian::weekday &wd) NOEXCEPT
Definition: julian.h:1440
CONSTCD14 weekday & operator++() NOEXCEPT
Definition: julian.h:1211
static CONSTCD11 unsigned char weekday_from_days(int z) NOEXCEPT
Definition: julian.h:1187
CONSTCD14 weekday & operator--() NOEXCEPT
Definition: julian.h:1213
unsigned char wd_
Definition: julian.h:285
CONSTCD14 weekday & operator-=(const days &d) NOEXCEPT
Definition: julian.h:1228
CONSTCD11 weekday(unsigned wd) NOEXCEPT
Definition: julian.h:1195
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1241
weekday(int)=delete
CONSTCD14 weekday & operator+=(const days &d) NOEXCEPT
Definition: julian.h:1219
CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT
Definition: julian.h:1415
julian::month_day_last mdl_
Definition: julian.h:562
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1937
CONSTCD11 julian::year year() const NOEXCEPT
Definition: julian.h:1936
CONSTCD11 year_month_day_last(const julian::year &y, const julian::month_day_last &mdl) NOEXCEPT
Definition: julian.h:1894
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1977
CONSTCD14 julian::day day() const NOEXCEPT
Definition: julian.h:1950
CONSTCD11 julian::month_day_last month_day_last() const NOEXCEPT
Definition: julian.h:1942
CONSTCD14 year_month_day_last & operator+=(const months &m) NOEXCEPT
Definition: julian.h:1903
CONSTCD14 year_month_day_last & operator-=(const months &m) NOEXCEPT
Definition: julian.h:1912
static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT
Definition: julian.h:2272
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:2120
CONSTCD11 julian::day day() const NOEXCEPT
Definition: julian.h:2121
julian::month m_
Definition: julian.h:510
CONSTCD14 days to_days() const NOEXCEPT
Definition: julian.h:2162
julian::day d_
Definition: julian.h:511
CONSTCD14 year_month_day & operator-=(const months &m) NOEXCEPT
Definition: julian.h:2135
CONSTCD11 year_month_day(const julian::year &y, const julian::month &m, const julian::day &d) NOEXCEPT
Definition: julian.h:2092
julian::year y_
Definition: julian.h:509
CONSTCD11 julian::year year() const NOEXCEPT
Definition: julian.h:2119
CONSTCD14 year_month_day & operator+=(const months &m) NOEXCEPT
Definition: julian.h:2126
CONSTCD14 bool ok() const NOEXCEPT
Definition: julian.h:2195
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:2631
CONSTCD14 days to_days() const NOEXCEPT
Definition: julian.h:2639
CONSTCD11 julian::weekday_last weekday_last() const NOEXCEPT
Definition: julian.h:2609
julian::weekday_last wdl_
Definition: julian.h:697
CONSTCD14 year_month_weekday_last & operator-=(const months &m) NOEXCEPT
Definition: julian.h:2571
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:2596
CONSTCD11 julian::year year() const NOEXCEPT
Definition: julian.h:2595
CONSTCD11 julian::weekday weekday() const NOEXCEPT
Definition: julian.h:2601
CONSTCD14 year_month_weekday_last & operator+=(const months &m) NOEXCEPT
Definition: julian.h:2562
CONSTCD11 year_month_weekday_last(const julian::year &y, const julian::month &m, const julian::weekday_last &wdl) NOEXCEPT
Definition: julian.h:2551
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:2399
CONSTCD11 year_month_weekday(const julian::year &y, const julian::month &m, const julian::weekday_indexed &wdi) NOEXCEPT
Definition: julian.h:2342
CONSTCD14 year_month_weekday & operator-=(const months &m) NOEXCEPT
Definition: julian.h:2374
CONSTCD14 year_month_weekday & operator+=(const months &m) NOEXCEPT
Definition: julian.h:2365
CONSTCD11 julian::weekday_indexed weekday_indexed() const NOEXCEPT
Definition: julian.h:2420
static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT
Definition: julian.h:2455
CONSTCD14 bool ok() const NOEXCEPT
Definition: julian.h:2442
CONSTCD11 julian::year year() const NOEXCEPT
Definition: julian.h:2398
CONSTCD11 julian::weekday weekday() const NOEXCEPT
Definition: julian.h:2404
CONSTCD14 days to_days() const NOEXCEPT
Definition: julian.h:2466
julian::weekday_indexed wdi_
Definition: julian.h:630
julian::month m_
Definition: julian.h:629
CONSTCD11 unsigned index() const NOEXCEPT
Definition: julian.h:2412
CONSTCD14 year_month & operator-=(const months &dm) NOEXCEPT
Definition: julian.h:1499
julian::month m_
Definition: julian.h:369
CONSTCD14 year_month & operator+=(const months &dm) NOEXCEPT
Definition: julian.h:1490
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1485
CONSTCD11 julian::month month() const NOEXCEPT
Definition: julian.h:1484
julian::year y_
Definition: julian.h:368
CONSTCD11 julian::year year() const NOEXCEPT
Definition: julian.h:1483
CONSTCD11 year_month(const julian::year &y, const julian::month &m) NOEXCEPT
Definition: julian.h:1478
CONSTCD14 year & operator++() NOEXCEPT
Definition: julian.h:1055
CONSTCD14 year & operator-=(const years &y) NOEXCEPT
Definition: julian.h:1060
CONSTCD11 bool is_leap() const NOEXCEPT
Definition: julian.h:1065
CONSTCD11 bool ok() const NOEXCEPT
Definition: julian.h:1071
CONSTCD14 year & operator--() NOEXCEPT
Definition: julian.h:1057
static CONSTCD11 year max() NOEXCEPT
Definition: julian.h:1084
CONSTCD14 year & operator+=(const years &y) NOEXCEPT
Definition: julian.h:1059
short y_
Definition: julian.h:243
static CONSTCD11 year min() NOEXCEPT
Definition: julian.h:1076
CONSTCD11 year(int y) NOEXCEPT
Definition: julian.h:1054
#define NOEXCEPT
Definition: date.h:135
#define CONSTDATA
Definition: date.h:132
#define CONSTCD14
Definition: date.h:134
#define CONSTCD11
Definition: date.h:133
decltype(std::ratio_divide< R1, R2 >{}) ratio_divide
Definition: date.h:167
decltype(std::ratio_multiply< R1, R2 >{}) ratio_multiply
Definition: date.h:164
local_time< days > local_days
Definition: date.h:202
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 7 >, days::period > > weeks
Definition: date.h:180
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > > days
Definition: date.h:177
sys_time< days > sys_days
Definition: date.h:193
CONSTDATA julian::month oct
Definition: julian.h:1361
CONSTDATA julian::month jul
Definition: julian.h:1358
CONSTDATA julian::weekday fri
Definition: julian.h:1370
CONSTDATA julian::month apr
Definition: julian.h:1355
CONSTDATA julian::month feb
Definition: julian.h:1353
CONSTDATA julian::month sep
Definition: julian.h:1360
CONSTDATA julian::weekday sun
Definition: julian.h:1365
CONSTDATA julian::month dec
Definition: julian.h:1363
CONSTDATA julian::weekday tue
Definition: julian.h:1367
CONSTDATA julian::month jan
Definition: julian.h:1352
CONSTDATA julian::month nov
Definition: julian.h:1362
CONSTDATA julian::weekday mon
Definition: julian.h:1366
CONSTDATA julian::last_spec last
Definition: julian.h:1350
CONSTDATA julian::weekday sat
Definition: julian.h:1371
CONSTDATA julian::weekday thu
Definition: julian.h:1369
CONSTDATA julian::weekday wed
Definition: julian.h:1368
CONSTDATA julian::month aug
Definition: julian.h:1359
CONSTDATA julian::month jun
Definition: julian.h:1357
CONSTDATA julian::month mar
Definition: julian.h:1354
CONSTDATA julian::month may
Definition: julian.h:1356
Definition: julian.h:33
CONSTCD11 day operator+(const day &x, const days &y) NOEXCEPT
Definition: julian.h:856
std::chrono::duration< int, date::detail::ratio_divide< years::period, std::ratio< 12 > > > months
Definition: julian.h:45
CONSTCD11 bool operator>=(const day &x, const day &y) NOEXCEPT
Definition: julian.h:839
CONSTCD11 bool operator!=(const day &x, const day &y) NOEXCEPT
Definition: julian.h:807
CONSTCD11 bool operator>(const day &x, const day &y) NOEXCEPT
Definition: julian.h:823
date::weeks weeks
Definition: julian.h:39
date::sys_days sys_days
Definition: julian.h:49
date::days days
Definition: julian.h:37
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const day &d)
Definition: julian.h:880
CONSTCD11 day operator-(const day &x, const days &y) NOEXCEPT
Definition: julian.h:872
std::chrono::duration< int, date::detail::ratio_multiply< std::ratio< 1461, 4 >, days::period > > years
Definition: julian.h:42
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
Definition: julian.h:799
CONSTCD11 year_month operator/(const year &y, const month &m) NOEXCEPT
Definition: julian.h:2723
CONSTCD11 bool operator<=(const day &x, const day &y) NOEXCEPT
Definition: julian.h:831
date::local_days local_days
Definition: julian.h:50
CONSTCD11 bool operator<(const day &x, const day &y) NOEXCEPT
Definition: julian.h:815
Namespace for mathematical applications.
Definition: muParser.cpp:53
#define min(a, b)
Definition: resampler.cpp:34
#define max(a, b)
Definition: resampler.cpp:30
last_spec()=default