NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
islamic.h
Go to the documentation of this file.
1#ifndef ISLAMIC_H
2#define ISLAMIC_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 islamic
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 CONSTCD14 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 islamic::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 islamic::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:
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 islamic::day operator "" _d(unsigned long long d) NOEXCEPT;
762CONSTCD11 islamic::year operator "" _y(unsigned long long y) NOEXCEPT;
763
764} // inline namespace literals
765#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
766
767//----------------+
768// Implementation |
769//----------------+
770
771// day
772
773CONSTCD11 inline day::day(unsigned d) NOEXCEPT : d_(static_cast<unsigned char>(d)) {}
774CONSTCD14 inline day& day::operator++() NOEXCEPT {++d_; return *this;}
775CONSTCD14 inline day day::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
776CONSTCD14 inline day& day::operator--() NOEXCEPT {--d_; return *this;}
777CONSTCD14 inline day day::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
778CONSTCD14 inline day& day::operator+=(const days& d) NOEXCEPT {*this = *this + d; return *this;}
779CONSTCD14 inline day& day::operator-=(const days& d) NOEXCEPT {*this = *this - d; return *this;}
780CONSTCD11 inline day::operator unsigned() const NOEXCEPT {return d_;}
781CONSTCD11 inline bool day::ok() const NOEXCEPT {return 1 <= d_ && d_ <= 30;}
782
784inline
785bool
786operator==(const day& x, const day& y) NOEXCEPT
787{
788 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
789}
790
792inline
793bool
794operator!=(const day& x, const day& y) NOEXCEPT
795{
796 return !(x == y);
797}
798
800inline
801bool
802operator<(const day& x, const day& y) NOEXCEPT
803{
804 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
805}
806
808inline
809bool
810operator>(const day& x, const day& y) NOEXCEPT
811{
812 return y < x;
813}
814
816inline
817bool
818operator<=(const day& x, const day& y) NOEXCEPT
819{
820 return !(y < x);
821}
822
824inline
825bool
826operator>=(const day& x, const day& y) NOEXCEPT
827{
828 return !(x < y);
829}
830
832inline
833days
834operator-(const day& x, const day& y) NOEXCEPT
835{
836 return days{static_cast<days::rep>(static_cast<unsigned>(x)
837 - static_cast<unsigned>(y))};
838}
839
841inline
842day
843operator+(const day& x, const days& y) NOEXCEPT
844{
845 return day{static_cast<unsigned>(x) + static_cast<unsigned>(y.count())};
846}
847
849inline
850day
851operator+(const days& x, const day& y) NOEXCEPT
852{
853 return y + x;
854}
855
857inline
858day
859operator-(const day& x, const days& y) NOEXCEPT
860{
861 return x + -y;
862}
863
864template<class CharT, class Traits>
865inline
866std::basic_ostream<CharT, Traits>&
867operator<<(std::basic_ostream<CharT, Traits>& os, const day& d)
868{
870 os.fill('0');
871 os.flags(std::ios::dec | std::ios::right);
872 os.width(2);
873 os << static_cast<unsigned>(d);
874 return os;
875}
876
877// month
878
879CONSTCD11 inline month::month(unsigned m) NOEXCEPT : m_(static_cast<decltype(m_)>(m)) {}
880CONSTCD14 inline month& month::operator++() NOEXCEPT {if (++m_ == 13) m_ = 1; return *this;}
881CONSTCD14 inline month month::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
882CONSTCD14 inline month& month::operator--() NOEXCEPT {if (--m_ == 0) m_ = 12; return *this;}
883CONSTCD14 inline month month::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
884
886inline
887month&
889{
890 *this = *this + m;
891 return *this;
892}
893
895inline
896month&
898{
899 *this = *this - m;
900 return *this;
901}
902
903CONSTCD11 inline month::operator unsigned() const NOEXCEPT {return m_;}
904CONSTCD11 inline bool month::ok() const NOEXCEPT {return 1 <= m_ && m_ <= 12;}
905
907inline
908bool
909operator==(const month& x, const month& y) NOEXCEPT
910{
911 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
912}
913
915inline
916bool
917operator!=(const month& x, const month& y) NOEXCEPT
918{
919 return !(x == y);
920}
921
923inline
924bool
925operator<(const month& x, const month& y) NOEXCEPT
926{
927 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
928}
929
931inline
932bool
933operator>(const month& x, const month& y) NOEXCEPT
934{
935 return y < x;
936}
937
939inline
940bool
941operator<=(const month& x, const month& y) NOEXCEPT
942{
943 return !(y < x);
944}
945
947inline
948bool
949operator>=(const month& x, const month& y) NOEXCEPT
950{
951 return !(x < y);
952}
953
955inline
956months
957operator-(const month& x, const month& y) NOEXCEPT
958{
959 auto const d = static_cast<unsigned>(x) - static_cast<unsigned>(y);
960 return months(d <= 11 ? d : d + 12);
961}
962
964inline
965month
966operator+(const month& x, const months& y) NOEXCEPT
967{
968 auto const mu = static_cast<long long>(static_cast<unsigned>(x)) - 1 + y.count();
969 auto const yr = (mu >= 0 ? mu : mu-11) / 12;
970 return month{static_cast<unsigned>(mu - yr * 12 + 1)};
971}
972
974inline
975month
976operator+(const months& x, const month& y) NOEXCEPT
977{
978 return y + x;
979}
980
982inline
983month
984operator-(const month& x, const months& y) NOEXCEPT
985{
986 return x + -y;
987}
988
989template<class CharT, class Traits>
990inline
991std::basic_ostream<CharT, Traits>&
992operator<<(std::basic_ostream<CharT, Traits>& os, const month& m)
993{
994 switch (static_cast<unsigned>(m))
995 {
996 case 1:
997 os << "Muharram";
998 break;
999 case 2:
1000 os << "Safar";
1001 break;
1002 case 3:
1003 os << "Rabi' al-awwal";
1004 break;
1005 case 4:
1006 os << "Rabi' al-thani";
1007 break;
1008 case 5:
1009 os << "Jumada al-awwal";
1010 break;
1011 case 6:
1012 os << "Jumada al-Thani";
1013 break;
1014 case 7:
1015 os << "Rajab";
1016 break;
1017 case 8:
1018 os << "Sha'ban";
1019 break;
1020 case 9:
1021 os << "Ramadan";
1022 break;
1023 case 10:
1024 os << "Shawwal";
1025 break;
1026 case 11:
1027 os << "Dhu al-Qi'dah";
1028 break;
1029 case 12:
1030 os << "Dhu al-Hijjah";
1031 break;
1032 default:
1033 os << static_cast<unsigned>(m) << " is not a valid month";
1034 break;
1035 }
1036 return os;
1037}
1038
1039// year
1040
1041CONSTCD11 inline year::year(int y) NOEXCEPT : y_(static_cast<decltype(y_)>(y)) {}
1042CONSTCD14 inline year& year::operator++() NOEXCEPT {++y_; return *this;}
1043CONSTCD14 inline year year::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
1044CONSTCD14 inline year& year::operator--() NOEXCEPT {--y_; return *this;}
1045CONSTCD14 inline year year::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
1046CONSTCD14 inline year& year::operator+=(const years& y) NOEXCEPT {*this = *this + y; return *this;}
1047CONSTCD14 inline year& year::operator-=(const years& y) NOEXCEPT {*this = *this - y; return *this;}
1048
1050inline
1051bool
1053{
1054 int y = y_ - 1;
1055 const int era = (y >= 0 ? y : y-29) / 30;
1056 const unsigned yoe = static_cast<unsigned>(y - era * 30);
1057 switch (yoe)
1058 {
1059 case 1:
1060 case 4:
1061 case 6:
1062 case 9:
1063 case 12:
1064 case 15:
1065 case 17:
1066 case 20:
1067 case 23:
1068 case 25:
1069 case 28:
1070 return true;
1071 default:
1072 return false;
1073 }
1074}
1075
1076CONSTCD11 inline year::operator int() const NOEXCEPT {return y_;}
1077CONSTCD11 inline bool year::ok() const NOEXCEPT {return true;}
1078
1080inline
1081year
1083{
1085}
1086
1088inline
1089year
1091{
1093}
1094
1096inline
1097bool
1098operator==(const year& x, const year& y) NOEXCEPT
1099{
1100 return static_cast<int>(x) == static_cast<int>(y);
1101}
1102
1104inline
1105bool
1106operator!=(const year& x, const year& y) NOEXCEPT
1107{
1108 return !(x == y);
1109}
1110
1112inline
1113bool
1114operator<(const year& x, const year& y) NOEXCEPT
1115{
1116 return static_cast<int>(x) < static_cast<int>(y);
1117}
1118
1120inline
1121bool
1122operator>(const year& x, const year& y) NOEXCEPT
1123{
1124 return y < x;
1125}
1126
1128inline
1129bool
1130operator<=(const year& x, const year& y) NOEXCEPT
1131{
1132 return !(y < x);
1133}
1134
1136inline
1137bool
1138operator>=(const year& x, const year& y) NOEXCEPT
1139{
1140 return !(x < y);
1141}
1142
1144inline
1145years
1146operator-(const year& x, const year& y) NOEXCEPT
1147{
1148 return years{static_cast<int>(x) - static_cast<int>(y)};
1149}
1150
1152inline
1153year
1154operator+(const year& x, const years& y) NOEXCEPT
1155{
1156 return year{static_cast<int>(x) + y.count()};
1157}
1158
1160inline
1161year
1162operator+(const years& x, const year& y) NOEXCEPT
1163{
1164 return y + x;
1165}
1166
1168inline
1169year
1170operator-(const year& x, const years& y) NOEXCEPT
1171{
1172 return year{static_cast<int>(x) - y.count()};
1173}
1174
1175template<class CharT, class Traits>
1176inline
1177std::basic_ostream<CharT, Traits>&
1178operator<<(std::basic_ostream<CharT, Traits>& os, const year& y)
1179{
1181 os.fill('0');
1182 os.flags(std::ios::dec | std::ios::internal);
1183 os.width(4 + (y < year{0}));
1184 os << static_cast<int>(y);
1185 return os;
1186}
1187
1188// weekday
1189
1191inline
1192unsigned char
1194{
1195 return static_cast<unsigned char>(static_cast<unsigned>(
1196 z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6));
1197}
1198
1200inline
1202 : wd_(static_cast<decltype(wd_)>(wd))
1203 {}
1204
1206inline
1208 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1209 {}
1210
1212inline
1214 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1215 {}
1216
1217CONSTCD14 inline weekday& weekday::operator++() NOEXCEPT {if (++wd_ == 7) wd_ = 0; return *this;}
1218CONSTCD14 inline weekday weekday::operator++(int) NOEXCEPT {auto tmp(*this); ++(*this); return tmp;}
1219CONSTCD14 inline weekday& weekday::operator--() NOEXCEPT {if (wd_-- == 0) wd_ = 6; return *this;}
1220CONSTCD14 inline weekday weekday::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;}
1221
1223inline
1224weekday&
1226{
1227 *this = *this + d;
1228 return *this;
1229}
1230
1232inline
1233weekday&
1235{
1236 *this = *this - d;
1237 return *this;
1238}
1239
1241inline
1242weekday::operator unsigned() const NOEXCEPT
1243{
1244 return static_cast<unsigned>(wd_);
1245}
1246
1247CONSTCD11 inline bool weekday::ok() const NOEXCEPT {return wd_ <= 6;}
1248
1250inline
1251bool
1253{
1254 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
1255}
1256
1258inline
1259bool
1261{
1262 return !(x == y);
1263}
1264
1266inline
1267days
1269{
1270 auto const diff = static_cast<unsigned>(x) - static_cast<unsigned>(y);
1271 return days{diff <= 6 ? diff : diff + 7};
1272}
1273
1275inline
1276weekday
1277operator+(const weekday& x, const days& y) NOEXCEPT
1278{
1279 auto const wdu = static_cast<long long>(static_cast<unsigned>(x)) + y.count();
1280 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1281 return weekday{static_cast<unsigned>(wdu - wk * 7)};
1282}
1283
1285inline
1286weekday
1287operator+(const days& x, const weekday& y) NOEXCEPT
1288{
1289 return y + x;
1290}
1291
1293inline
1294weekday
1295operator-(const weekday& x, const days& y) NOEXCEPT
1296{
1297 return x + -y;
1298}
1299
1300template<class CharT, class Traits>
1301inline
1302std::basic_ostream<CharT, Traits>&
1303operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd)
1304{
1305 switch (static_cast<unsigned>(wd))
1306 {
1307 case 0:
1308 os << "al-Aḥad";
1309 break;
1310 case 1:
1311 os << "al-Ithnayn";
1312 break;
1313 case 2:
1314 os << "ath-Thulāthā’";
1315 break;
1316 case 3:
1317 os << "al-Arba‘ā’";
1318 break;
1319 case 4:
1320 os << "al-Khamīs";
1321 break;
1322 case 5:
1323 os << "al-Jum‘ah";
1324 break;
1325 case 6:
1326 os << "as-Sabt";
1327 break;
1328 default:
1329 os << static_cast<unsigned>(wd) << " is not a valid weekday";
1330 break;
1331 }
1332 return os;
1333}
1334
1335#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1336inline namespace literals
1337{
1338
1340inline
1342operator "" _d(unsigned long long d) NOEXCEPT
1343{
1344 return islamic::day{static_cast<unsigned>(d)};
1345}
1346
1348inline
1350operator "" _y(unsigned long long y) NOEXCEPT
1351{
1352 return islamic::year(static_cast<int>(y));
1353}
1354#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
1355
1357
1358#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1359} // inline namespace literals
1360#endif
1361
1362// weekday_indexed
1363
1365inline
1366weekday
1368{
1369 return islamic::weekday{static_cast<unsigned>(wd_)};
1370}
1371
1372CONSTCD11 inline unsigned weekday_indexed::index() const NOEXCEPT {return index_;}
1373
1375inline
1376bool
1378{
1379 return weekday().ok() && 1 <= index_ && index_ <= 5;
1380}
1381
1383inline
1385 : wd_(static_cast<decltype(wd_)>(static_cast<unsigned>(wd)))
1386 , index_(static_cast<decltype(index_)>(index))
1387 {}
1388
1389template<class CharT, class Traits>
1390inline
1391std::basic_ostream<CharT, Traits>&
1392operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi)
1393{
1394 return os << wdi.weekday() << '[' << wdi.index() << ']';
1395}
1396
1398inline
1399weekday_indexed
1400weekday::operator[](unsigned index) const NOEXCEPT
1401{
1402 return {*this, index};
1403}
1404
1406inline
1407bool
1409{
1410 return x.weekday() == y.weekday() && x.index() == y.index();
1411}
1412
1414inline
1415bool
1417{
1418 return !(x == y);
1419}
1420
1421// weekday_last
1422
1424CONSTCD11 inline bool weekday_last::ok() const NOEXCEPT {return wd_.ok();}
1426
1428inline
1429bool
1431{
1432 return x.weekday() == y.weekday();
1433}
1434
1436inline
1437bool
1439{
1440 return !(x == y);
1441}
1442
1443template<class CharT, class Traits>
1444inline
1445std::basic_ostream<CharT, Traits>&
1446operator<<(std::basic_ostream<CharT, Traits>& os, const weekday_last& wdl)
1447{
1448 return os << wdl.weekday() << "[last]";
1449}
1450
1452inline
1453weekday_last
1455{
1456 return weekday_last{*this};
1457}
1458
1459// year_month
1460
1462inline
1464 : y_(y)
1465 , m_(m)
1466 {}
1467
1468CONSTCD11 inline year year_month::year() const NOEXCEPT {return y_;}
1469CONSTCD11 inline month year_month::month() const NOEXCEPT {return m_;}
1470CONSTCD11 inline bool year_month::ok() const NOEXCEPT {return y_.ok() && m_.ok();}
1471
1473inline
1476{
1477 *this = *this + dm;
1478 return *this;
1479}
1480
1482inline
1485{
1486 *this = *this - dm;
1487 return *this;
1488}
1489
1491inline
1494{
1495 *this = *this + dy;
1496 return *this;
1497}
1498
1500inline
1503{
1504 *this = *this - dy;
1505 return *this;
1506}
1507
1509inline
1510bool
1512{
1513 return x.year() == y.year() && x.month() == y.month();
1514}
1515
1517inline
1518bool
1520{
1521 return !(x == y);
1522}
1523
1525inline
1526bool
1527operator<(const year_month& x, const year_month& y) NOEXCEPT
1528{
1529 return x.year() < y.year() ? true
1530 : (x.year() > y.year() ? false
1531 : (x.month() < y.month()));
1532}
1533
1535inline
1536bool
1538{
1539 return y < x;
1540}
1541
1543inline
1544bool
1545operator<=(const year_month& x, const year_month& y) NOEXCEPT
1546{
1547 return !(y < x);
1548}
1549
1551inline
1552bool
1554{
1555 return !(x < y);
1556}
1557
1559inline
1560year_month
1562{
1563 auto dmi = static_cast<int>(static_cast<unsigned>(ym.month())) - 1 + dm.count();
1564 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
1565 dmi = dmi - dy * 12 + 1;
1566 return (ym.year() + years(dy)) / month(static_cast<unsigned>(dmi));
1567}
1568
1570inline
1571year_month
1573{
1574 return ym + dm;
1575}
1576
1578inline
1579year_month
1581{
1582 return ym + -dm;
1583}
1584
1586inline
1587months
1589{
1590 return (x.year() - y.year()) +
1591 months(static_cast<unsigned>(x.month()) - static_cast<unsigned>(y.month()));
1592}
1593
1595inline
1596year_month
1597operator+(const year_month& ym, const years& dy) NOEXCEPT
1598{
1599 return (ym.year() + dy) / ym.month();
1600}
1601
1603inline
1604year_month
1605operator+(const years& dy, const year_month& ym) NOEXCEPT
1606{
1607 return ym + dy;
1608}
1609
1611inline
1612year_month
1613operator-(const year_month& ym, const years& dy) NOEXCEPT
1614{
1615 return ym + -dy;
1616}
1617
1618template<class CharT, class Traits>
1619inline
1620std::basic_ostream<CharT, Traits>&
1621operator<<(std::basic_ostream<CharT, Traits>& os, const year_month& ym)
1622{
1623 return os << ym.year() << '/' << ym.month();
1624}
1625
1626// month_day
1627
1629inline
1631 : m_(m)
1632 , d_(d)
1633 {}
1634
1637
1639inline
1640bool
1642{
1644 {30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 30_d};
1645 return m_.ok() && 1_d <= d_ && d_ <= d[static_cast<unsigned>(m_)-1];
1646}
1647
1649inline
1650bool
1652{
1653 return x.month() == y.month() && x.day() == y.day();
1654}
1655
1657inline
1658bool
1660{
1661 return !(x == y);
1662}
1663
1665inline
1666bool
1667operator<(const month_day& x, const month_day& y) NOEXCEPT
1668{
1669 return x.month() < y.month() ? true
1670 : (x.month() > y.month() ? false
1671 : (x.day() < y.day()));
1672}
1673
1675inline
1676bool
1678{
1679 return y < x;
1680}
1681
1683inline
1684bool
1685operator<=(const month_day& x, const month_day& y) NOEXCEPT
1686{
1687 return !(y < x);
1688}
1689
1691inline
1692bool
1694{
1695 return !(x < y);
1696}
1697
1698template<class CharT, class Traits>
1699inline
1700std::basic_ostream<CharT, Traits>&
1701operator<<(std::basic_ostream<CharT, Traits>& os, const month_day& md)
1702{
1703 return os << md.month() << '/' << md.day();
1704}
1705
1706// month_day_last
1707
1709CONSTCD11 inline bool month_day_last::ok() const NOEXCEPT {return m_.ok();}
1711
1713inline
1714bool
1716{
1717 return x.month() == y.month();
1718}
1719
1721inline
1722bool
1724{
1725 return !(x == y);
1726}
1727
1729inline
1730bool
1732{
1733 return x.month() < y.month();
1734}
1735
1737inline
1738bool
1740{
1741 return y < x;
1742}
1743
1745inline
1746bool
1748{
1749 return !(y < x);
1750}
1751
1753inline
1754bool
1756{
1757 return !(x < y);
1758}
1759
1760template<class CharT, class Traits>
1761inline
1762std::basic_ostream<CharT, Traits>&
1763operator<<(std::basic_ostream<CharT, Traits>& os, const month_day_last& mdl)
1764{
1765 return os << mdl.month() << "/last";
1766}
1767
1768// month_weekday
1769
1771inline
1774 : m_(m)
1775 , wdi_(wdi)
1776 {}
1777
1779
1781inline
1784{
1785 return wdi_;
1786}
1787
1789inline
1790bool
1792{
1793 return m_.ok() && wdi_.ok();
1794}
1795
1797inline
1798bool
1800{
1801 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
1802}
1803
1805inline
1806bool
1808{
1809 return !(x == y);
1810}
1811
1812template<class CharT, class Traits>
1813inline
1814std::basic_ostream<CharT, Traits>&
1815operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday& mwd)
1816{
1817 return os << mwd.month() << '/' << mwd.weekday_indexed();
1818}
1819
1820// month_weekday_last
1821
1823inline
1826 : m_(m)
1827 , wdl_(wdl)
1828 {}
1829
1831
1833inline
1836{
1837 return wdl_;
1838}
1839
1841inline
1842bool
1844{
1845 return m_.ok() && wdl_.ok();
1846}
1847
1849inline
1850bool
1852{
1853 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
1854}
1855
1857inline
1858bool
1860{
1861 return !(x == y);
1862}
1863
1864template<class CharT, class Traits>
1865inline
1866std::basic_ostream<CharT, Traits>&
1867operator<<(std::basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl)
1868{
1869 return os << mwdl.month() << '/' << mwdl.weekday_last();
1870}
1871
1872// year_month_day_last
1873
1875inline
1878 : y_(y)
1879 , mdl_(mdl)
1880 {}
1881
1883inline
1886{
1887 *this = *this + m;
1888 return *this;
1889}
1890
1892inline
1895{
1896 *this = *this - m;
1897 return *this;
1898}
1899
1901inline
1904{
1905 *this = *this + y;
1906 return *this;
1907}
1908
1910inline
1913{
1914 *this = *this - y;
1915 return *this;
1916}
1917
1920
1922inline
1925{
1926 return mdl_;
1927}
1928
1930inline
1931day
1933{
1935 {30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 29_d, 30_d, 29_d};
1936 return month() != islamic::month(12) || !y_.is_leap() ?
1937 d[static_cast<unsigned>(month())-1] : 30_d;
1938}
1939
1941inline
1942year_month_day_last::operator sys_days() const NOEXCEPT
1943{
1944 return sys_days(year()/month()/day());
1945}
1946
1948inline
1949year_month_day_last::operator local_days() const NOEXCEPT
1950{
1951 return local_days(year()/month()/day());
1952}
1953
1955inline
1956bool
1958{
1959 return y_.ok() && mdl_.ok();
1960}
1961
1963inline
1964bool
1966{
1967 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
1968}
1969
1971inline
1972bool
1974{
1975 return !(x == y);
1976}
1977
1979inline
1980bool
1982{
1983 return x.year() < y.year() ? true
1984 : (x.year() > y.year() ? false
1985 : (x.month_day_last() < y.month_day_last()));
1986}
1987
1989inline
1990bool
1992{
1993 return y < x;
1994}
1995
1997inline
1998bool
2000{
2001 return !(y < x);
2002}
2003
2005inline
2006bool
2008{
2009 return !(x < y);
2010}
2011
2012template<class CharT, class Traits>
2013inline
2014std::basic_ostream<CharT, Traits>&
2015operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl)
2016{
2017 return os << ymdl.year() << '/' << ymdl.month_day_last();
2018}
2019
2021inline
2022year_month_day_last
2024{
2025 return (ymdl.year() / ymdl.month() + dm) / last;
2026}
2027
2029inline
2030year_month_day_last
2032{
2033 return ymdl + dm;
2034}
2035
2037inline
2038year_month_day_last
2040{
2041 return ymdl + (-dm);
2042}
2043
2045inline
2046year_month_day_last
2048{
2049 return {ymdl.year()+dy, ymdl.month_day_last()};
2050}
2051
2053inline
2054year_month_day_last
2056{
2057 return ymdl + dy;
2058}
2059
2061inline
2062year_month_day_last
2064{
2065 return ymdl + (-dy);
2066}
2067
2068// year_month_day
2069
2071inline
2073 const islamic::day& d) NOEXCEPT
2074 : y_(y)
2075 , m_(m)
2076 , d_(d)
2077 {}
2078
2080inline
2082 : y_(ymdl.year())
2083 , m_(ymdl.month())
2084 , d_(ymdl.day())
2085 {}
2086
2088inline
2090 : year_month_day(from_days(dp.time_since_epoch()))
2091 {}
2092
2094inline
2096 : year_month_day(from_days(dp.time_since_epoch()))
2097 {}
2098
2099CONSTCD11 inline year year_month_day::year() const NOEXCEPT {return y_;}
2102
2104inline
2107{
2108 *this = *this + m;
2109 return *this;
2110}
2111
2113inline
2116{
2117 *this = *this - m;
2118 return *this;
2119}
2120
2122inline
2125{
2126 *this = *this + y;
2127 return *this;
2128}
2129
2131inline
2134{
2135 *this = *this - y;
2136 return *this;
2137}
2138
2140inline
2141days
2143{
2144 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2145 "This algorithm has not been ported to a 16 bit unsigned integer");
2146 static_assert(std::numeric_limits<int>::digits >= 20,
2147 "This algorithm has not been ported to a 16 bit signed integer");
2148 auto const y = static_cast<int>(y_) - 1;
2149 auto const m = static_cast<unsigned>(m_);
2150 auto const d = static_cast<unsigned>(d_);
2151 auto const era = (y >= 0 ? y : y-29) / 30;
2152 auto const yoe = static_cast<unsigned>(y - era * 30); // [0, 29]
2153 auto const doy = 29*(m-1) + m/2 + d-1; // [0, 354]
2154 auto const doe = yoe * 354 + (11*(yoe+1)+3)/30 + doy; // [0, 10630]
2155 return days{era * 10631 + static_cast<int>(doe) - 492148};
2156}
2157
2159inline
2160year_month_day::operator sys_days() const NOEXCEPT
2161{
2162 return sys_days{to_days()};
2163}
2164
2166inline
2167year_month_day::operator local_days() const NOEXCEPT
2168{
2169 return local_days{to_days()};
2170}
2171
2173inline
2174bool
2176{
2177 if (!(y_.ok() && m_.ok()))
2178 return false;
2179 return 1_d <= d_ && d_ <= (y_/m_/last).day();
2180}
2181
2183inline
2184bool
2186{
2187 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
2188}
2189
2191inline
2192bool
2194{
2195 return !(x == y);
2196}
2197
2199inline
2200bool
2202{
2203 return x.year() < y.year() ? true
2204 : (x.year() > y.year() ? false
2205 : (x.month() < y.month() ? true
2206 : (x.month() > y.month() ? false
2207 : (x.day() < y.day()))));
2208}
2209
2211inline
2212bool
2214{
2215 return y < x;
2216}
2217
2219inline
2220bool
2222{
2223 return !(y < x);
2224}
2225
2227inline
2228bool
2230{
2231 return !(x < y);
2232}
2233
2234template<class CharT, class Traits>
2235inline
2236std::basic_ostream<CharT, Traits>&
2237operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_day& ymd)
2238{
2240 os.fill('0');
2241 os.flags(std::ios::dec | std::ios::right);
2242 os << ymd.year() << '-';
2243 os.width(2);
2244 os << static_cast<unsigned>(ymd.month()) << '-';
2245 os << ymd.day();
2246 return os;
2247}
2248
2250inline
2251year_month_day
2253{
2254 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2255 "This algorithm has not been ported to a 16 bit unsigned integer");
2256 static_assert(std::numeric_limits<int>::digits >= 20,
2257 "This algorithm has not been ported to a 16 bit signed integer");
2258 auto const z = dp.count() + 492148;
2259 auto const era = (z >= 0 ? z : z - 10630) / 10631;
2260 auto const doe = static_cast<unsigned>(z - era * 10631); // [0, 10630]
2261 auto const yoe = (30*doe + 10646)/10631 - 1; // [0, 29]
2262 auto const y = static_cast<sys_days::rep>(yoe) + era * 30 + 1;
2263 auto const doy = doe - (yoe * 354 + (11*(yoe+1)+3)/30); // [0, 354]
2264 auto const m = (11*doy + 330) / 325; // [1, 12]
2265 auto const d = doy - (29*(m-1) + m/2) + 1; // [1, 30]
2267}
2268
2270inline
2273{
2274 return (ymd.year() / ymd.month() + dm) / ymd.day();
2275}
2276
2278inline
2279year_month_day
2281{
2282 return ymd + dm;
2283}
2284
2286inline
2287year_month_day
2289{
2290 return ymd + (-dm);
2291}
2292
2294inline
2295year_month_day
2297{
2298 return (ymd.year() + dy) / ymd.month() / ymd.day();
2299}
2300
2302inline
2303year_month_day
2305{
2306 return ymd + dy;
2307}
2308
2310inline
2311year_month_day
2313{
2314 return ymd + (-dy);
2315}
2316
2317// year_month_weekday
2318
2320inline
2322 const islamic::weekday_indexed& wdi)
2323 NOEXCEPT
2324 : y_(y)
2325 , m_(m)
2326 , wdi_(wdi)
2327 {}
2328
2330inline
2332 : year_month_weekday(from_days(dp.time_since_epoch()))
2333 {}
2334
2336inline
2338 : year_month_weekday(from_days(dp.time_since_epoch()))
2339 {}
2340
2342inline
2345{
2346 *this = *this + m;
2347 return *this;
2348}
2349
2351inline
2354{
2355 *this = *this - m;
2356 return *this;
2357}
2358
2360inline
2363{
2364 *this = *this + y;
2365 return *this;
2366}
2367
2369inline
2372{
2373 *this = *this - y;
2374 return *this;
2375}
2376
2379
2381inline
2382weekday
2384{
2385 return wdi_.weekday();
2386}
2387
2389inline
2390unsigned
2392{
2393 return wdi_.index();
2394}
2395
2397inline
2400{
2401 return wdi_;
2402}
2403
2405inline
2406year_month_weekday::operator sys_days() const NOEXCEPT
2407{
2408 return sys_days{to_days()};
2409}
2410
2412inline
2413year_month_weekday::operator local_days() const NOEXCEPT
2414{
2415 return local_days{to_days()};
2416}
2417
2419inline
2420bool
2422{
2423 if (!y_.ok() || !m_.ok() || !wdi_.weekday().ok() || wdi_.index() < 1)
2424 return false;
2425 if (wdi_.index() <= 4)
2426 return true;
2427 auto d2 = wdi_.weekday() - islamic::weekday(y_/m_/1) + days((wdi_.index()-1)*7 + 1);
2428 return static_cast<unsigned>(d2.count()) <= static_cast<unsigned>((y_/m_/last).day());
2429}
2430
2432inline
2435{
2436 sys_days dp{d};
2437 auto const wd = islamic::weekday(dp);
2438 auto const ymd = year_month_day(dp);
2439 return {ymd.year(), ymd.month(), wd[(static_cast<unsigned>(ymd.day())-1)/7+1]};
2440}
2441
2443inline
2444days
2446{
2447 auto d = sys_days(y_/m_/1);
2448 return (d + (wdi_.weekday() - islamic::weekday(d) + days{(wdi_.index()-1)*7})
2449 ).time_since_epoch();
2450}
2451
2453inline
2454bool
2456{
2457 return x.year() == y.year() && x.month() == y.month() &&
2458 x.weekday_indexed() == y.weekday_indexed();
2459}
2460
2462inline
2463bool
2465{
2466 return !(x == y);
2467}
2468
2469template<class CharT, class Traits>
2470inline
2471std::basic_ostream<CharT, Traits>&
2472operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwdi)
2473{
2474 return os << ymwdi.year() << '/' << ymwdi.month()
2475 << '/' << ymwdi.weekday_indexed();
2476}
2477
2479inline
2480year_month_weekday
2482{
2483 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
2484}
2485
2487inline
2488year_month_weekday
2490{
2491 return ymwd + dm;
2492}
2493
2495inline
2496year_month_weekday
2498{
2499 return ymwd + (-dm);
2500}
2501
2503inline
2504year_month_weekday
2506{
2507 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
2508}
2509
2511inline
2512year_month_weekday
2514{
2515 return ymwd + dy;
2516}
2517
2519inline
2520year_month_weekday
2522{
2523 return ymwd + (-dy);
2524}
2525
2526// year_month_weekday_last
2527
2529inline
2531 const islamic::month& m,
2533 : y_(y)
2534 , m_(m)
2535 , wdl_(wdl)
2536 {}
2537
2539inline
2542{
2543 *this = *this + m;
2544 return *this;
2545}
2546
2548inline
2551{
2552 *this = *this - m;
2553 return *this;
2554}
2555
2557inline
2560{
2561 *this = *this + y;
2562 return *this;
2563}
2564
2566inline
2569{
2570 *this = *this - y;
2571 return *this;
2572}
2573
2576
2578inline
2579weekday
2581{
2582 return wdl_.weekday();
2583}
2584
2586inline
2589{
2590 return wdl_;
2591}
2592
2594inline
2595year_month_weekday_last::operator sys_days() const NOEXCEPT
2596{
2597 return sys_days{to_days()};
2598}
2599
2601inline
2602year_month_weekday_last::operator local_days() const NOEXCEPT
2603{
2604 return local_days{to_days()};
2605}
2606
2608inline
2609bool
2611{
2612 return y_.ok() && m_.ok() && wdl_.ok();
2613}
2614
2616inline
2617days
2619{
2620 auto const d = sys_days(y_/m_/last);
2621 return (d - (islamic::weekday{d} - wdl_.weekday())).time_since_epoch();
2622}
2623
2625inline
2626bool
2628{
2629 return x.year() == y.year() && x.month() == y.month() &&
2630 x.weekday_last() == y.weekday_last();
2631}
2632
2634inline
2635bool
2637{
2638 return !(x == y);
2639}
2640
2641template<class CharT, class Traits>
2642inline
2643std::basic_ostream<CharT, Traits>&
2644operator<<(std::basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl)
2645{
2646 return os << ymwdl.year() << '/' << ymwdl.month() << '/' << ymwdl.weekday_last();
2647}
2648
2650inline
2651year_month_weekday_last
2653{
2654 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
2655}
2656
2658inline
2659year_month_weekday_last
2661{
2662 return ymwdl + dm;
2663}
2664
2666inline
2667year_month_weekday_last
2669{
2670 return ymwdl + (-dm);
2671}
2672
2674inline
2675year_month_weekday_last
2677{
2678 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
2679}
2680
2682inline
2683year_month_weekday_last
2685{
2686 return ymwdl + dy;
2687}
2688
2690inline
2691year_month_weekday_last
2693{
2694 return ymwdl + (-dy);
2695}
2696
2697// year_month from operator/()
2698
2700inline
2701year_month
2702operator/(const year& y, const month& m) NOEXCEPT
2703{
2704 return {y, m};
2705}
2706
2708inline
2709year_month
2710operator/(const year& y, int m) NOEXCEPT
2711{
2712 return y / month(static_cast<unsigned>(m));
2713}
2714
2715// month_day from operator/()
2716
2718inline
2719month_day
2720operator/(const month& m, const day& d) NOEXCEPT
2721{
2722 return {m, d};
2723}
2724
2726inline
2727month_day
2728operator/(const day& d, const month& m) NOEXCEPT
2729{
2730 return m / d;
2731}
2732
2734inline
2735month_day
2736operator/(const month& m, int d) NOEXCEPT
2737{
2738 return m / day(static_cast<unsigned>(d));
2739}
2740
2742inline
2743month_day
2744operator/(int m, const day& d) NOEXCEPT
2745{
2746 return month(static_cast<unsigned>(m)) / d;
2747}
2748
2749CONSTCD11 inline month_day operator/(const day& d, int m) NOEXCEPT {return m / d;}
2750
2751// month_day_last from operator/()
2752
2754inline
2755month_day_last
2757{
2758 return month_day_last{m};
2759}
2760
2762inline
2763month_day_last
2765{
2766 return m/last;
2767}
2768
2770inline
2771month_day_last
2773{
2774 return month(static_cast<unsigned>(m))/last;
2775}
2776
2778inline
2779month_day_last
2781{
2782 return m/last;
2783}
2784
2785// month_weekday from operator/()
2786
2788inline
2789month_weekday
2791{
2792 return {m, wdi};
2793}
2794
2796inline
2797month_weekday
2799{
2800 return m / wdi;
2801}
2802
2804inline
2805month_weekday
2807{
2808 return month(static_cast<unsigned>(m)) / wdi;
2809}
2810
2812inline
2813month_weekday
2815{
2816 return m / wdi;
2817}
2818
2819// month_weekday_last from operator/()
2820
2822inline
2823month_weekday_last
2825{
2826 return {m, wdl};
2827}
2828
2830inline
2831month_weekday_last
2833{
2834 return m / wdl;
2835}
2836
2838inline
2839month_weekday_last
2841{
2842 return month(static_cast<unsigned>(m)) / wdl;
2843}
2844
2846inline
2847month_weekday_last
2849{
2850 return m / wdl;
2851}
2852
2853// year_month_day from operator/()
2854
2856inline
2857year_month_day
2858operator/(const year_month& ym, const day& d) NOEXCEPT
2859{
2860 return {ym.year(), ym.month(), d};
2861}
2862
2864inline
2865year_month_day
2867{
2868 return ym / day(static_cast<unsigned>(d));
2869}
2870
2872inline
2873year_month_day
2874operator/(const year& y, const month_day& md) NOEXCEPT
2875{
2876 return y / md.month() / md.day();
2877}
2878
2880inline
2881year_month_day
2883{
2884 return year(y) / md;
2885}
2886
2888inline
2889year_month_day
2890operator/(const month_day& md, const year& y) NOEXCEPT
2891{
2892 return y / md;
2893}
2894
2896inline
2897year_month_day
2899{
2900 return year(y) / md;
2901}
2902
2903// year_month_day_last from operator/()
2904
2906inline
2907year_month_day_last
2909{
2910 return {ym.year(), month_day_last{ym.month()}};
2911}
2912
2914inline
2915year_month_day_last
2917{
2918 return {y, mdl};
2919}
2920
2922inline
2923year_month_day_last
2925{
2926 return year(y) / mdl;
2927}
2928
2930inline
2931year_month_day_last
2933{
2934 return y / mdl;
2935}
2936
2938inline
2939year_month_day_last
2941{
2942 return year(y) / mdl;
2943}
2944
2945// year_month_weekday from operator/()
2946
2948inline
2949year_month_weekday
2951{
2952 return {ym.year(), ym.month(), wdi};
2953}
2954
2956inline
2957year_month_weekday
2959{
2960 return {y, mwd.month(), mwd.weekday_indexed()};
2961}
2962
2964inline
2965year_month_weekday
2967{
2968 return year(y) / mwd;
2969}
2970
2972inline
2973year_month_weekday
2975{
2976 return y / mwd;
2977}
2978
2980inline
2981year_month_weekday
2983{
2984 return year(y) / mwd;
2985}
2986
2987// year_month_weekday_last from operator/()
2988
2990inline
2991year_month_weekday_last
2993{
2994 return {ym.year(), ym.month(), wdl};
2995}
2996
2998inline
2999year_month_weekday_last
3001{
3002 return {y, mwdl.month(), mwdl.weekday_last()};
3003}
3004
3006inline
3007year_month_weekday_last
3009{
3010 return year(y) / mwdl;
3011}
3012
3014inline
3015year_month_weekday_last
3017{
3018 return y / mwdl;
3019}
3020
3022inline
3023year_month_weekday_last
3025{
3026 return year(y) / mwdl;
3027}
3028
3029} // namespace islamic
3030
3031#endif // ISLAMIC_H
CONSTCD14 day & operator++() NOEXCEPT
Definition: islamic.h:774
CONSTCD14 day & operator-=(const days &d) NOEXCEPT
Definition: islamic.h:779
CONSTCD11 day(unsigned d) NOEXCEPT
Definition: islamic.h:773
CONSTCD14 day & operator--() NOEXCEPT
Definition: islamic.h:776
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:781
CONSTCD14 day & operator+=(const days &d) NOEXCEPT
Definition: islamic.h:778
unsigned char d_
Definition: islamic.h:169
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1708
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1709
CONSTCD11 month_day_last(const islamic::month &m) NOEXCEPT
Definition: islamic.h:1710
islamic::month m_
Definition: islamic.h:436
islamic::day d_
Definition: islamic.h:410
CONSTCD11 month_day(const islamic::month &m, const islamic::day &d) NOEXCEPT
Definition: islamic.h:1630
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1635
islamic::month m_
Definition: islamic.h:409
CONSTCD14 bool ok() const NOEXCEPT
Definition: islamic.h:1641
CONSTCD11 islamic::day day() const NOEXCEPT
Definition: islamic.h:1636
islamic::weekday_last wdl_
Definition: islamic.h:484
CONSTCD11 month_weekday_last(const islamic::month &m, const islamic::weekday_last &wd) NOEXCEPT
Definition: islamic.h:1824
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1843
CONSTCD11 islamic::weekday_last weekday_last() const NOEXCEPT
Definition: islamic.h:1835
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1830
CONSTCD11 month_weekday(const islamic::month &m, const islamic::weekday_indexed &wdi) NOEXCEPT
Definition: islamic.h:1772
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1778
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1791
islamic::weekday_indexed wdi_
Definition: islamic.h:461
islamic::month m_
Definition: islamic.h:460
CONSTCD11 islamic::weekday_indexed weekday_indexed() const NOEXCEPT
Definition: islamic.h:1783
CONSTCD11 month(unsigned m) NOEXCEPT
Definition: islamic.h:879
CONSTCD14 month & operator++() NOEXCEPT
Definition: islamic.h:880
CONSTCD14 month & operator+=(const months &m) NOEXCEPT
Definition: islamic.h:888
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:904
CONSTCD14 month & operator--() NOEXCEPT
Definition: islamic.h:882
unsigned char m_
Definition: islamic.h:206
CONSTCD14 month & operator-=(const months &m) NOEXCEPT
Definition: islamic.h:897
CONSTCD11 unsigned index() const NOEXCEPT
Definition: islamic.h:1372
CONSTCD11 weekday_indexed(const islamic::weekday &wd, unsigned index) NOEXCEPT
Definition: islamic.h:1384
unsigned char wd_
Definition: islamic.h:326
CONSTCD11 islamic::weekday weekday() const NOEXCEPT
Definition: islamic.h:1367
unsigned char index_
Definition: islamic.h:327
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1377
islamic::weekday wd_
Definition: islamic.h:348
CONSTCD11 islamic::weekday weekday() const NOEXCEPT
Definition: islamic.h:1423
CONSTCD11 weekday_last(const islamic::weekday &wd) NOEXCEPT
Definition: islamic.h:1425
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1424
weekday(int)=delete
CONSTCD14 weekday & operator--() NOEXCEPT
Definition: islamic.h:1219
CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT
Definition: islamic.h:1400
CONSTCD14 weekday & operator-=(const days &d) NOEXCEPT
Definition: islamic.h:1234
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1247
static CONSTCD11 unsigned char weekday_from_days(int z) NOEXCEPT
Definition: islamic.h:1193
unsigned char wd_
Definition: islamic.h:285
CONSTCD11 weekday(unsigned wd) NOEXCEPT
Definition: islamic.h:1201
CONSTCD14 weekday & operator++() NOEXCEPT
Definition: islamic.h:1217
CONSTCD14 weekday & operator+=(const days &d) NOEXCEPT
Definition: islamic.h:1225
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1957
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1919
CONSTCD14 year_month_day_last & operator-=(const months &m) NOEXCEPT
Definition: islamic.h:1894
CONSTCD14 year_month_day_last & operator+=(const months &m) NOEXCEPT
Definition: islamic.h:1885
CONSTCD14 islamic::day day() const NOEXCEPT
Definition: islamic.h:1932
CONSTCD11 islamic::month_day_last month_day_last() const NOEXCEPT
Definition: islamic.h:1924
islamic::month_day_last mdl_
Definition: islamic.h:562
CONSTCD11 islamic::year year() const NOEXCEPT
Definition: islamic.h:1918
CONSTCD11 year_month_day_last(const islamic::year &y, const islamic::month_day_last &mdl) NOEXCEPT
Definition: islamic.h:1876
islamic::month m_
Definition: islamic.h:510
CONSTCD14 days to_days() const NOEXCEPT
Definition: islamic.h:2142
CONSTCD11 islamic::day day() const NOEXCEPT
Definition: islamic.h:2101
islamic::day d_
Definition: islamic.h:511
CONSTCD14 year_month_day & operator+=(const months &m) NOEXCEPT
Definition: islamic.h:2106
CONSTCD11 islamic::year year() const NOEXCEPT
Definition: islamic.h:2099
islamic::year y_
Definition: islamic.h:509
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:2100
static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT
Definition: islamic.h:2252
CONSTCD14 year_month_day & operator-=(const months &m) NOEXCEPT
Definition: islamic.h:2115
CONSTCD14 bool ok() const NOEXCEPT
Definition: islamic.h:2175
CONSTCD11 year_month_day(const islamic::year &y, const islamic::month &m, const islamic::day &d) NOEXCEPT
Definition: islamic.h:2072
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:2575
islamic::weekday_last wdl_
Definition: islamic.h:697
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:2610
CONSTCD14 year_month_weekday_last & operator-=(const months &m) NOEXCEPT
Definition: islamic.h:2550
CONSTCD11 islamic::year year() const NOEXCEPT
Definition: islamic.h:2574
CONSTCD11 islamic::weekday_last weekday_last() const NOEXCEPT
Definition: islamic.h:2588
CONSTCD14 year_month_weekday_last & operator+=(const months &m) NOEXCEPT
Definition: islamic.h:2541
CONSTCD11 year_month_weekday_last(const islamic::year &y, const islamic::month &m, const islamic::weekday_last &wdl) NOEXCEPT
Definition: islamic.h:2530
CONSTCD14 days to_days() const NOEXCEPT
Definition: islamic.h:2618
CONSTCD11 islamic::weekday weekday() const NOEXCEPT
Definition: islamic.h:2580
static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT
Definition: islamic.h:2434
CONSTCD14 year_month_weekday & operator+=(const months &m) NOEXCEPT
Definition: islamic.h:2344
CONSTCD14 year_month_weekday & operator-=(const months &m) NOEXCEPT
Definition: islamic.h:2353
CONSTCD11 year_month_weekday(const islamic::year &y, const islamic::month &m, const islamic::weekday_indexed &wdi) NOEXCEPT
Definition: islamic.h:2321
CONSTCD14 days to_days() const NOEXCEPT
Definition: islamic.h:2445
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:2378
CONSTCD11 islamic::year year() const NOEXCEPT
Definition: islamic.h:2377
CONSTCD11 unsigned index() const NOEXCEPT
Definition: islamic.h:2391
CONSTCD11 islamic::weekday weekday() const NOEXCEPT
Definition: islamic.h:2383
islamic::weekday_indexed wdi_
Definition: islamic.h:630
CONSTCD11 islamic::weekday_indexed weekday_indexed() const NOEXCEPT
Definition: islamic.h:2399
CONSTCD14 bool ok() const NOEXCEPT
Definition: islamic.h:2421
islamic::month m_
Definition: islamic.h:369
CONSTCD11 year_month(const islamic::year &y, const islamic::month &m) NOEXCEPT
Definition: islamic.h:1463
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1470
CONSTCD14 year_month & operator+=(const months &dm) NOEXCEPT
Definition: islamic.h:1475
CONSTCD14 year_month & operator-=(const months &dm) NOEXCEPT
Definition: islamic.h:1484
CONSTCD11 islamic::month month() const NOEXCEPT
Definition: islamic.h:1469
islamic::year y_
Definition: islamic.h:368
CONSTCD11 islamic::year year() const NOEXCEPT
Definition: islamic.h:1468
CONSTCD14 year & operator++() NOEXCEPT
Definition: islamic.h:1042
CONSTCD14 year & operator-=(const years &y) NOEXCEPT
Definition: islamic.h:1047
static CONSTCD11 year min() NOEXCEPT
Definition: islamic.h:1082
CONSTCD14 bool is_leap() const NOEXCEPT
Definition: islamic.h:1052
CONSTCD14 year & operator--() NOEXCEPT
Definition: islamic.h:1044
CONSTCD11 year(int y) NOEXCEPT
Definition: islamic.h:1041
static CONSTCD11 year max() NOEXCEPT
Definition: islamic.h:1090
CONSTCD14 year & operator+=(const years &y) NOEXCEPT
Definition: islamic.h:1046
CONSTCD11 bool ok() const NOEXCEPT
Definition: islamic.h:1077
short y_
Definition: islamic.h:243
#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
CONSTDATA date::month dec
Definition: date.h:2002
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 islamic::last_spec last
Definition: islamic.h:1356
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const day &d)
Definition: islamic.h:867
CONSTCD11 bool operator>=(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:826
std::chrono::duration< int, date::detail::ratio_multiply< std::ratio< 10631, 30 >, days::period > > years
Definition: islamic.h:42
CONSTCD11 bool operator!=(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:794
CONSTCD11 bool operator>(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:810
CONSTCD11 bool operator<(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:802
CONSTCD11 day operator+(const day &x, const days &y) NOEXCEPT
Definition: islamic.h:843
CONSTCD11 day operator-(const day &x, const days &y) NOEXCEPT
Definition: islamic.h:859
date::sys_days sys_days
Definition: islamic.h:49
CONSTCD11 year_month operator/(const year &y, const month &m) NOEXCEPT
Definition: islamic.h:2702
date::weeks weeks
Definition: islamic.h:39
CONSTCD11 bool operator<=(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:818
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
Definition: islamic.h:786
date::local_days local_days
Definition: islamic.h:50
std::chrono::duration< int, date::detail::ratio_divide< years::period, std::ratio< 12 > > > months
Definition: islamic.h:45
date::days days
Definition: islamic.h:37
Namespace for mathematical applications.
Definition: muParser.cpp:53
#define min(a, b)
Definition: resampler.cpp:34
#define max(a, b)
Definition: resampler.cpp:30