0.2.0
Loading...
Searching...
No Matches
InsTime.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
17
18#pragma once
19
20#include <string>
21#include <array>
22#include <limits>
23#include <iostream>
24#include <chrono>
25
26#include <fmt/ostream.h>
27#include "gcem.hpp"
28
29#include <nlohmann/json.hpp>
30using json = nlohmann::json;
31
32#include "TimeSystem.hpp"
34
35namespace NAV
36{
38namespace InsTimeUtil
39{
40constexpr int32_t END_OF_THE_CENTURY_MJD = 400000;
41constexpr int32_t WEEKS_PER_GPS_CYCLE = 1024;
42constexpr int32_t DIFF_TO_6_1_1980_MJD = 44244;
43constexpr int32_t DIFF_TO_1_1_1970_MJD = 40587;
44constexpr int32_t DIFF_BDT_WEEK_TO_GPST_WEEK = 1356;
45
46constexpr int32_t DIFF_MJD_TO_JD_DAYS = 2400000;
47constexpr long double DIFF_MJD_TO_JD_FRAC = 0.5L;
48
49constexpr int32_t MONTHS_PER_YEAR = 12;
50constexpr int32_t DAYS_PER_YEAR = 365;
51constexpr int32_t DAYS_PER_WEEK = 7;
52constexpr int32_t HOURS_PER_DAY = 24;
54constexpr int32_t MINUTES_PER_HOUR = 60;
57constexpr int32_t SECONDS_PER_MINUTE = 60;
61
66constexpr long double EPSILON = std::max(1e-17L, 10 * std::numeric_limits<long double>::epsilon());
67
69constexpr std::array<int32_t, 20> GPS_LEAP_SEC_MJD = {
70 0, // + 0 at 1 Jan 1980 and before
71 44786, // + 1 at 1 Jul 1981 = diff UTC-TAI: 20
72 45151, // + 2 at 1 Jul 1982 = diff UTC-TAI: 21
73 45516, // + 3 at 1 Jul 1983 = diff UTC-TAI: 22
74 46247, // + 4 at 1 Jul 1985 = diff UTC-TAI: 23
75 47161, // + 5 at 1 Jan 1988 = diff UTC-TAI: 24
76 47892, // + 6 at 1 Jan 1990 = diff UTC-TAI: 25
77 48257, // + 7 at 1 Jan 1991 = diff UTC-TAI: 26
78 48804, // + 8 at 1 Jul 1992 = diff UTC-TAI: 27
79 49169, // + 9 at 1 Jul 1993 = diff UTC-TAI: 28
80 49534, // +10 at 1 Jul 1994 = diff UTC-TAI: 29
81 50083, // +11 at 1 Jan 1996 = diff UTC-TAI: 30
82 50630, // +12 at 1 Jul 1997 = diff UTC-TAI: 31
83 51179, // +13 at 1 Jan 1999 = diff UTC-TAI: 32
84 53736, // +14 at 1 Jan 2006 = diff UTC-TAI: 33
85 54832, // +15 at 1 Jan 2009 = diff UTC-TAI: 34
86 56109, // +16 at 1 Jul 2012 = diff UTC-TAI: 35
87 57204, // +17 at 1 Jul 2015 = diff UTC-TAI: 36
88 57754, // +18 at 1 Jan 2017 = diff UTC-TAI: 37
89 99999, // future
90};
91
95constexpr bool isLeapYear(int32_t year)
96{
97 return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
98}
99
104constexpr int32_t daysInMonth(int32_t month, int32_t year)
105{
106 --month; // Make month 0 based
107 if (month >= InsTimeUtil::MONTHS_PER_YEAR)
108 {
109 year += month / InsTimeUtil::MONTHS_PER_YEAR;
111 }
112 while (month < 0)
113 {
114 month += MONTHS_PER_YEAR;
115 year--;
116 }
117 ++month; // Make month 1 based
118
119 switch (month)
120 {
121 case 1:
122 return 31;
123 case 2:
124 if (isLeapYear(year))
125 {
126 return 29;
127 }
128 return 28;
129 case 3:
130 return 31;
131 case 4:
132 return 30;
133 case 5:
134 return 31;
135 case 6:
136 return 30;
137 case 7:
138 return 31;
139 case 8:
140 return 31;
141 case 9:
142 return 30;
143 case 10:
144 return 31;
145 case 11:
146 return 30;
147 case 12:
148 return 31;
149 default:
150 return 366;
151 }
152}
153} // namespace InsTimeUtil
154
157{
158 int32_t mjd_day = 0;
159 long double mjd_frac = 0.0L;
160
162 constexpr InsTime_MJD() = default;
163
167 constexpr InsTime_MJD(int32_t mjd_day, long double mjd_frac)
169 {
170 if (this->mjd_frac >= 1.0L)
171 {
172 this->mjd_day += static_cast<int32_t>(this->mjd_frac);
173 this->mjd_frac -= static_cast<int32_t>(this->mjd_frac);
174 }
175 while (this->mjd_frac < 0.0L)
176 {
177 this->mjd_frac += 1.0L;
178 this->mjd_day--;
179 }
180 }
181
185 constexpr bool operator==(const InsTime_MJD& rhs) const
186 {
187 if (mjd_day == rhs.mjd_day)
188 {
189 auto difference = gcem::abs(mjd_frac - rhs.mjd_frac);
190 return difference <= InsTimeUtil::EPSILON;
191 }
192 if (auto diffDays = mjd_day - rhs.mjd_day;
193 gcem::abs(diffDays) == 1)
194 {
195 auto difference = 1 + diffDays * (mjd_frac - rhs.mjd_frac);
196 return difference <= InsTimeUtil::EPSILON;
197 }
198 return false;
199 }
203 constexpr bool operator!=(const InsTime_MJD& rhs) const
204 {
205 return !(*this == rhs);
206 }
210 constexpr bool operator<=(const InsTime_MJD& rhs) const
211 {
212 return *this < rhs || *this == rhs;
213 }
217 constexpr bool operator>=(const InsTime_MJD& rhs) const
218 {
219 return *this > rhs || *this == rhs;
220 }
224 constexpr bool operator<(const InsTime_MJD& rhs) const
225 {
226 return (mjd_day < rhs.mjd_day || (mjd_day == rhs.mjd_day && mjd_frac < rhs.mjd_frac))
227 && *this != rhs;
228 }
232 constexpr bool operator>(const InsTime_MJD& rhs) const
233 {
234 return !(*this <= rhs);
235 }
236
238 explicit operator std::string() const;
239};
240
243{
244 int32_t jd_day{};
245 long double jd_frac{};
246
250 constexpr InsTime_JD(int32_t jd_day, long double jd_frac)
252 {
253 if (this->jd_frac >= 1.0L)
254 {
255 this->jd_day += static_cast<int32_t>(this->jd_frac);
256 this->jd_frac -= static_cast<int32_t>(this->jd_frac);
257 }
258 while (this->jd_frac < 0.0L)
259 {
260 this->jd_frac += 1.0L;
261 this->jd_day--;
262 }
263 }
264
268 constexpr bool operator==(const InsTime_JD& rhs) const
269 {
270 if (jd_day == rhs.jd_day)
271 {
272 auto difference = gcem::abs(jd_frac - rhs.jd_frac);
273 return difference <= InsTimeUtil::EPSILON;
274 }
275 if (auto diffDays = jd_day - rhs.jd_day;
276 gcem::abs(diffDays) == 1)
277 {
278 auto difference = 1 + diffDays * (jd_frac - rhs.jd_frac);
279 return difference <= InsTimeUtil::EPSILON;
280 }
281 return false;
282 }
286 constexpr bool operator!=(const InsTime_JD& rhs) const
287 {
288 return !(*this == rhs);
289 }
293 constexpr bool operator<=(const InsTime_JD& rhs) const
294 {
295 return *this < rhs || *this == rhs;
296 }
300 constexpr bool operator>=(const InsTime_JD& rhs) const
301 {
302 return *this > rhs || *this == rhs;
303 }
307 constexpr bool operator<(const InsTime_JD& rhs) const
308 {
309 return (jd_day < rhs.jd_day || (jd_day == rhs.jd_day && jd_frac < rhs.jd_frac))
310 && *this != rhs;
311 }
315 constexpr bool operator>(const InsTime_JD& rhs) const
316 {
317 return !(*this <= rhs);
318 }
319
321 explicit operator std::string() const;
322};
323
326{
327 int32_t gpsCycle{};
328 int32_t gpsWeek{};
329 long double tow{};
330
335 constexpr InsTime_GPSweekTow(int32_t gpsCycle, int32_t gpsWeek, long double tow)
337 {
338 if (this->tow >= InsTimeUtil::SECONDS_PER_WEEK)
339 {
340 this->gpsWeek += static_cast<int32_t>(this->tow / InsTimeUtil::SECONDS_PER_WEEK);
341 this->tow = gcem::fmod(this->tow, InsTimeUtil::SECONDS_PER_WEEK);
342 }
343 while (this->tow < 0.0L)
344 {
346 this->gpsWeek--;
347 }
348
349 if (this->gpsWeek >= InsTimeUtil::WEEKS_PER_GPS_CYCLE)
350 {
351 this->gpsCycle += this->gpsWeek / InsTimeUtil::WEEKS_PER_GPS_CYCLE;
352 this->gpsWeek %= InsTimeUtil::WEEKS_PER_GPS_CYCLE;
353 }
354 while (this->gpsWeek < 0)
355 {
356 this->gpsWeek += InsTimeUtil::WEEKS_PER_GPS_CYCLE;
357 this->gpsCycle--;
358 }
359 };
360
364 constexpr bool operator==(const InsTime_GPSweekTow& rhs) const
365 {
366 if (gpsCycle == rhs.gpsCycle && gpsWeek == rhs.gpsWeek)
367 {
368 return gcem::abs(tow - rhs.tow) <= InsTimeUtil::EPSILON;
369 }
371 gcem::abs(diffWeeks) == 1)
372 {
373 return gcem::abs(tow + diffWeeks * InsTimeUtil::SECONDS_PER_WEEK - rhs.tow) <= InsTimeUtil::EPSILON;
374 }
375 return false;
376 }
380 constexpr bool operator!=(const InsTime_GPSweekTow& rhs) const
381 {
382 return !(*this == rhs);
383 }
387 constexpr bool operator<=(const InsTime_GPSweekTow& rhs) const
388 {
389 return *this < rhs || *this == rhs;
390 }
394 constexpr bool operator>=(const InsTime_GPSweekTow& rhs) const
395 {
396 return *this > rhs || *this == rhs;
397 }
401 constexpr bool operator<(const InsTime_GPSweekTow& rhs) const
402 {
403 return (gpsCycle < rhs.gpsCycle
404 || (gpsCycle == rhs.gpsCycle && gpsWeek < rhs.gpsWeek)
405 || (gpsCycle == rhs.gpsCycle && gpsWeek == rhs.gpsWeek && tow < rhs.tow))
406 && *this != rhs;
407 }
411 constexpr bool operator>(const InsTime_GPSweekTow& rhs) const
412 {
413 return !(*this <= rhs);
414 }
415
417 explicit operator std::string() const;
418};
419
422{
423 int32_t year{};
424 int32_t month{};
425 int32_t day{};
426 int32_t hour{};
427 int32_t min{};
428 long double sec{};
429
438 constexpr InsTime_YMDHMS(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, long double sec, int digits = -1)
440 {
441 if (digits >= 0) { this->sec = math::round(this->sec, static_cast<size_t>(digits)); }
442 if (this->sec >= InsTimeUtil::SECONDS_PER_MINUTE)
443 {
444 this->min += static_cast<int32_t>(this->sec / InsTimeUtil::SECONDS_PER_MINUTE);
445 this->sec = gcem::fmod(this->sec, InsTimeUtil::SECONDS_PER_MINUTE);
446 }
447 while (this->sec < 0.0L)
448 {
450 this->min--;
451 }
452 if (digits >= 0) { this->sec = math::round(this->sec, static_cast<size_t>(digits)); }
453
454 if (this->min >= InsTimeUtil::MINUTES_PER_HOUR)
455 {
456 this->hour += this->min / InsTimeUtil::MINUTES_PER_HOUR;
458 }
459 while (this->min < 0)
460 {
462 this->hour--;
463 }
464
465 if (this->hour >= InsTimeUtil::HOURS_PER_DAY)
466 {
467 this->day += this->hour / InsTimeUtil::HOURS_PER_DAY;
468 this->hour %= InsTimeUtil::HOURS_PER_DAY;
469 }
470 while (this->hour < 0)
471 {
472 this->hour += InsTimeUtil::HOURS_PER_DAY;
473 this->day--;
474 }
475
476 while (this->day >= InsTimeUtil::DAYS_PER_YEAR + static_cast<int32_t>(InsTimeUtil::isLeapYear(this->year)))
477 {
478 this->day -= InsTimeUtil::DAYS_PER_YEAR + static_cast<int32_t>(InsTimeUtil::isLeapYear(this->year));
479 this->year++;
480 }
481
482 while (this->day > InsTimeUtil::daysInMonth(this->month, this->year))
483 {
484 this->day -= InsTimeUtil::daysInMonth(this->month, this->year);
485 this->month++;
486 }
487 while (this->day < 1)
488 {
489 this->month--;
490 this->day += InsTimeUtil::daysInMonth(this->month, this->year);
491 }
492
493 while (this->month > InsTimeUtil::MONTHS_PER_YEAR)
494 {
495 this->month -= InsTimeUtil::MONTHS_PER_YEAR;
496 this->year++;
497 }
498 while (this->month < 1)
499 {
500 this->month += InsTimeUtil::MONTHS_PER_YEAR;
501 this->year--;
502 }
503 }
504
508 constexpr bool operator==(const InsTime_YMDHMS& rhs) const
509 {
510 if (year == rhs.year && month == rhs.month && day == rhs.day && hour == rhs.hour && min == rhs.min)
511 {
512 return gcem::abs(sec - rhs.sec) <= InsTimeUtil::EPSILON;
513 }
514 InsTime_YMDHMS this_plus = InsTime_YMDHMS(this->year, this->month, this->day, this->hour, this->min, this->sec + 10);
515 InsTime_YMDHMS rhs_plus = InsTime_YMDHMS(rhs.year, rhs.month, rhs.day, rhs.hour, rhs.min, rhs.sec + 10);
516 if (this_plus.year == rhs_plus.year && this_plus.month == rhs_plus.month && this_plus.day == rhs_plus.day && this_plus.hour == rhs_plus.hour && this_plus.min == rhs_plus.min)
517 {
518 return gcem::abs(this_plus.sec - rhs_plus.sec) <= InsTimeUtil::EPSILON;
519 }
520 return false;
521 }
525 constexpr bool operator!=(const InsTime_YMDHMS& rhs) const
526 {
527 return !(*this == rhs);
528 }
532 constexpr bool operator<=(const InsTime_YMDHMS& rhs) const
533 {
534 return *this < rhs || *this == rhs;
535 }
539 constexpr bool operator>=(const InsTime_YMDHMS& rhs) const
540 {
541 return *this > rhs || *this == rhs;
542 }
546 constexpr bool operator<(const InsTime_YMDHMS& rhs) const
547 {
548 return (year < rhs.year
549 || (year == rhs.year && month < rhs.month)
550 || (year == rhs.year && month == rhs.month && day < rhs.day)
551 || (year == rhs.year && month == rhs.month && day == rhs.day && hour < rhs.hour)
552 || (year == rhs.year && month == rhs.month && day == rhs.day && hour == rhs.hour && min < rhs.min)
553 || (year == rhs.year && month == rhs.month && day == rhs.day && hour == rhs.hour && min == rhs.min && sec < rhs.sec))
554 && *this != rhs;
555 }
559 constexpr bool operator>(const InsTime_YMDHMS& rhs) const
560 {
561 return !(*this <= rhs);
562 }
563
565 explicit operator std::string() const;
566};
567
570{
571 int32_t year{};
572 int32_t doy{};
573 long double sod{};
574
579 constexpr InsTime_YDoySod(int32_t year, int32_t doy, long double sod)
580 : year(year), doy(doy), sod(sod)
581 {
582 if (this->sod >= InsTimeUtil::SECONDS_PER_DAY)
583 {
584 this->doy += static_cast<int32_t>(this->sod / InsTimeUtil::SECONDS_PER_DAY);
585 this->sod = gcem::fmod(this->sod, InsTimeUtil::SECONDS_PER_DAY);
586 }
587 while (this->sod < 0)
588 {
589 this->sod += InsTimeUtil::SECONDS_PER_DAY;
590 this->doy--;
591 }
592
593 while (this->doy > InsTimeUtil::DAYS_PER_YEAR + static_cast<int32_t>(InsTimeUtil::isLeapYear(this->year)))
594 {
595 this->doy -= InsTimeUtil::DAYS_PER_YEAR + static_cast<int32_t>(InsTimeUtil::isLeapYear(this->year));
596 this->year++;
597 }
598 while (this->doy < 1)
599 {
600 this->doy += InsTimeUtil::DAYS_PER_YEAR + static_cast<int32_t>(InsTimeUtil::isLeapYear(this->year - 1));
601 this->year--;
602 }
603 }
604
608 constexpr bool operator==(const InsTime_YDoySod& rhs) const
609 {
610 if (year == rhs.year && doy == rhs.doy)
611 {
612 return gcem::abs(sod - rhs.sod) <= InsTimeUtil::EPSILON;
613 }
614 if (auto diffDays = year * InsTimeUtil::DAYS_PER_YEAR + doy - (rhs.year * InsTimeUtil::DAYS_PER_YEAR + rhs.doy);
615 gcem::abs(diffDays) == 1)
616 {
617 auto difference = gcem::abs(sod + diffDays * InsTimeUtil::SECONDS_PER_DAY - rhs.sod);
618 return difference <= InsTimeUtil::EPSILON;
619 }
620 return false;
621 }
625 constexpr bool operator!=(const InsTime_YDoySod& rhs) const
626 {
627 return !(*this == rhs);
628 }
632 constexpr bool operator<=(const InsTime_YDoySod& rhs) const
633 {
634 return *this < rhs || *this == rhs;
635 }
639 constexpr bool operator>=(const InsTime_YDoySod& rhs) const
640 {
641 return *this > rhs || *this == rhs;
642 }
646 constexpr bool operator<(const InsTime_YDoySod& rhs) const
647 {
648 return (year < rhs.year
649 || (year == rhs.year && doy < rhs.doy)
650 || (year == rhs.year && doy == rhs.doy && sod < rhs.sod))
651 && *this != rhs;
652 }
656 constexpr bool operator>(const InsTime_YDoySod& rhs) const
657 {
658 return !(*this <= rhs);
659 }
660
662 explicit operator std::string() const;
663};
664
667{
668 public:
669 /* ------------------------------ Constructors ------------------------------ */
670
672 constexpr InsTime() = default;
673
677 constexpr explicit InsTime(const InsTime_MJD& mjd, TimeSystem timesys = UTC)
678 : _mjd(mjd)
679 {
680 *this -= std::chrono::duration<long double>(differenceToUTC(timesys));
681 }
682
686 constexpr explicit InsTime(const InsTime_JD& jd, TimeSystem timesys = UTC)
687 : _mjd(jd.jd_day - InsTimeUtil::DIFF_MJD_TO_JD_DAYS, jd.jd_frac - InsTimeUtil::DIFF_MJD_TO_JD_FRAC)
688 {
689 *this -= std::chrono::duration<long double>(differenceToUTC(timesys));
690 }
691
695 constexpr explicit InsTime(const InsTime_GPSweekTow& gpsWeekTow, TimeSystem timesys = GPST)
696 {
697 auto mjd_day = static_cast<int32_t>((gpsWeekTow.gpsCycle * InsTimeUtil::WEEKS_PER_GPS_CYCLE + gpsWeekTow.gpsWeek) * InsTimeUtil::DAYS_PER_WEEK
698 + gcem::floor(gpsWeekTow.tow / InsTimeUtil::SECONDS_PER_DAY)
700 long double mjd_frac = gcem::fmod(gpsWeekTow.tow, InsTimeUtil::SECONDS_PER_DAY) / InsTimeUtil::SECONDS_PER_DAY;
701
702 _mjd = InsTime_MJD(mjd_day, mjd_frac);
703
704 *this -= std::chrono::duration<long double>(differenceToUTC(timesys));
705 }
706
710 constexpr explicit InsTime(const InsTime_YMDHMS& yearMonthDayHMS, TimeSystem timesys = UTC)
711 {
712 auto a = static_cast<int32_t>((14 - yearMonthDayHMS.month) / static_cast<double>(InsTimeUtil::MONTHS_PER_YEAR));
713 int32_t y = yearMonthDayHMS.year + 4800 - a;
714 int32_t m = yearMonthDayHMS.month + InsTimeUtil::MONTHS_PER_YEAR * a - 3;
715
716 auto jd_day = static_cast<int32_t>(yearMonthDayHMS.day
717 + gcem::floor((153.0 * static_cast<double>(m) + 2.0) / 5.0)
719 + gcem::floor(static_cast<double>(y) / 4.0)
720 - gcem::floor(static_cast<double>(y) / 100.0)
721 + gcem::floor(static_cast<double>(y) / 400.0)
722 - 32045);
723 auto jd_frac = (yearMonthDayHMS.sec
724 + static_cast<long double>(yearMonthDayHMS.min) * InsTimeUtil::SECONDS_PER_MINUTE
725 + static_cast<long double>(yearMonthDayHMS.hour - 12.0) * InsTimeUtil::SECONDS_PER_HOUR)
727
728 _mjd = InsTime(InsTime_JD(jd_day, jd_frac)).toMJD();
729
730 *this -= std::chrono::duration<long double>(differenceToUTC(timesys));
731 }
732
736 constexpr explicit InsTime(const InsTime_YDoySod& yearDoySod, TimeSystem timesys = UTC)
737 {
738 auto year = yearDoySod.year;
739 auto doy = yearDoySod.doy;
740 auto sod = yearDoySod.sod;
741
742 int32_t month = 1;
743 while (doy > InsTimeUtil::daysInMonth(month, year))
744 {
745 doy -= InsTimeUtil::daysInMonth(month, year);
746 month++;
747 }
748
749 _mjd = InsTime(InsTime_YMDHMS(year, month, doy, 0, 0, sod)).toMJD();
750
751 *this -= std::chrono::duration<long double>(differenceToUTC(timesys));
752 }
753
759 constexpr InsTime(int32_t gpsCycle, int32_t gpsWeek, long double tow, TimeSystem timesys = GPST)
760 : InsTime(InsTime_GPSweekTow(gpsCycle, gpsWeek, tow), timesys) {}
761
770 constexpr InsTime(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, long double sec, TimeSystem timesys = UTC)
771 : InsTime(InsTime_YMDHMS(year, month, day, hour, min, sec), timesys) {}
772
774 ~InsTime() = default;
776 constexpr InsTime(const InsTime&) = default;
778 constexpr InsTime(InsTime&&) = default;
780 constexpr InsTime& operator=(const InsTime&) = default;
782 constexpr InsTime& operator=(InsTime&&) = default;
783
784 /* ------------------------ Transformation functions ------------------------ */
785
789 [[nodiscard]] constexpr InsTime_MJD toMJD(TimeSystem timesys = UTC) const
790 {
791 long double mjdFrac = _mjd.mjd_frac + static_cast<long double>(differenceToUTC(timesys)) / static_cast<long double>(InsTimeUtil::SECONDS_PER_DAY);
792 return { _mjd.mjd_day, mjdFrac };
793 }
794
798 [[nodiscard]] constexpr InsTime_JD toJD(TimeSystem timesys = UTC) const
799 {
800 auto jd_day = _mjd.mjd_day + InsTimeUtil::DIFF_MJD_TO_JD_DAYS;
801 auto jd_frac = _mjd.mjd_frac + InsTimeUtil::DIFF_MJD_TO_JD_FRAC;
802
803 jd_frac += static_cast<long double>(differenceToUTC(timesys)) / static_cast<long double>(InsTimeUtil::SECONDS_PER_DAY);
804
805 return { jd_day, jd_frac };
806 }
807
811 [[nodiscard]] constexpr InsTime_GPSweekTow toGPSweekTow(TimeSystem timesys = GPST) const
812 {
813 InsTime_MJD mjd_leap = _mjd;
814 // Convert from UTC to intended time system
815 mjd_leap.mjd_frac += static_cast<long double>(differenceToUTC(timesys)) / static_cast<long double>(InsTimeUtil::SECONDS_PER_DAY);
816
817 // Put everything in the time of week, as it gets splitted in InsTime_GPSweekTow constructor
818 auto tow = static_cast<long double>((mjd_leap.mjd_day - InsTimeUtil::DIFF_TO_6_1_1980_MJD)) * InsTimeUtil::SECONDS_PER_DAY
820
821 return { 0, 0, tow };
822 }
823
828 [[nodiscard]] constexpr InsTime_YMDHMS toYMDHMS(TimeSystem timesys = UTC, int digits = -1) const
829 {
830 // transform MJD to JD
831 InsTime_JD jd = toJD();
832 jd.jd_frac = jd.jd_frac + 0.5L;
833 jd.jd_frac += static_cast<long double>(differenceToUTC(timesys)) / static_cast<long double>(InsTimeUtil::SECONDS_PER_DAY);
834 while (jd.jd_frac >= 1.0L)
835 {
836 jd.jd_day += 1;
837 jd.jd_frac -= 1.0L;
838 }
839 // transform JD to YMDHMS
840 double a = 32044.0 + jd.jd_day;
841 double b = gcem::floor((4.0 * a + 3.0) / 146097.0);
842 double c = a - gcem::floor((b * 146097.0) / 4.0);
843
844 double d = gcem::floor((4.0 * c + 3.0) / 1461.0);
845 double e = c - gcem::floor((1461.0 * d) / 4.0);
846 double m = gcem::floor((5.0 * e + 2.0) / 153.0);
847
848 auto day = static_cast<uint16_t>(e - gcem::floor((153.0 * m + 2.0) / 5.0) + 1);
849 auto month = static_cast<uint16_t>(m + 3 - 12 * gcem::floor(m / 10.0));
850 auto year = static_cast<uint16_t>(b * 100 + d - 4800.0 + gcem::floor(m / 10.0));
851
852 long double sec = jd.jd_frac * InsTimeUtil::SECONDS_PER_DAY;
853
854 return { year, month, day, 0, 0, sec, digits };
855 }
856
860 [[nodiscard]] constexpr InsTime_YDoySod toYDoySod(TimeSystem timesys = UTC) const
861 {
862 InsTime_YMDHMS yearMonthDayHMS = toYMDHMS();
863
864 auto year = yearMonthDayHMS.year;
865 long double sod = static_cast<long double>(yearMonthDayHMS.hour * InsTimeUtil::SECONDS_PER_HOUR
866 + yearMonthDayHMS.min * InsTimeUtil::SECONDS_PER_MINUTE)
867 + yearMonthDayHMS.sec
868 + static_cast<long double>(differenceToUTC(timesys));
869
870 int32_t doy = 0;
871 for (int32_t i = 1; i < yearMonthDayHMS.month; i++)
872 {
873 doy += InsTimeUtil::daysInMonth(i, year);
874 }
875 doy += yearMonthDayHMS.day;
876
877 return { year, doy, sod };
878 }
879
882 [[nodiscard]] constexpr InsTime toFullDay() const
883 {
884 return InsTime(InsTime_MJD(_mjd.mjd_day, 0.0L));
885 }
886
888 [[nodiscard]] constexpr long double toUnixTime() const
889 {
890 return static_cast<long double>((_mjd.mjd_day - InsTimeUtil::DIFF_TO_1_1_1970_MJD) * InsTimeUtil::SECONDS_PER_DAY)
892 }
893
894 /* ----------------------------- Leap functions ----------------------------- */
895
898 [[nodiscard]] constexpr uint16_t leapGps2UTC() const
899 {
900 return leapGps2UTC(_mjd);
901 }
902
906 static constexpr uint16_t leapGps2UTC(const InsTime& insTime)
907 {
908 return leapGps2UTC(insTime._mjd);
909 }
910
914 static constexpr uint16_t leapGps2UTC(const InsTime_GPSweekTow& gpsWeekTow)
915 {
916 return leapGps2UTC(InsTime(gpsWeekTow).toMJD());
917 }
918
922 static constexpr uint16_t leapGps2UTC(const InsTime_YDoySod& yearDoySod)
923 {
924 return leapGps2UTC(InsTime(yearDoySod).toMJD());
925 }
926
930 static constexpr uint16_t leapGps2UTC(const InsTime_YMDHMS& yearMonthDayHMS)
931 {
932 return leapGps2UTC(InsTime(yearMonthDayHMS).toMJD());
933 }
934
938 static constexpr uint16_t leapGps2UTC(const InsTime_JD& jd)
939 {
940 return leapGps2UTC(InsTime(jd).toMJD());
941 }
942
946 static constexpr uint16_t leapGps2UTC(const InsTime_MJD& mjd_in)
947 {
948 return static_cast<uint16_t>(std::upper_bound(InsTimeUtil::GPS_LEAP_SEC_MJD.begin(), InsTimeUtil::GPS_LEAP_SEC_MJD.end(), mjd_in.mjd_day) - InsTimeUtil::GPS_LEAP_SEC_MJD.begin() - 1);
949 }
950
953 [[nodiscard]] constexpr bool isLeapYear() const
954 {
955 return InsTimeUtil::isLeapYear(toYMDHMS().year);
956 }
957
958 /* --------------------- Comparison operator overloading -------------------- */
959
963 constexpr bool operator==(const InsTime& rhs) const { return _mjd == rhs._mjd; }
967 constexpr bool operator!=(const InsTime& rhs) const { return !(*this == rhs); }
971 constexpr bool operator<=(const InsTime& rhs) const { return *this < rhs || *this == rhs; }
975 constexpr bool operator>=(const InsTime& rhs) const { return *this > rhs || *this == rhs; }
979 constexpr bool operator<(const InsTime& rhs) const { return _mjd < rhs._mjd; }
983 constexpr bool operator>(const InsTime& rhs) const { return !(*this <= rhs); }
984
985 /* --------------------- Arithmetic operator overloading -------------------- */
986
991 constexpr friend std::chrono::duration<long double> operator-(const InsTime& lhs, const InsTime& rhs)
992 {
993 auto diffDays = lhs._mjd.mjd_day - rhs._mjd.mjd_day;
994 auto diffFrac = lhs._mjd.mjd_frac - rhs._mjd.mjd_frac;
995 long double diffSec = (diffFrac + static_cast<long double>(diffDays)) * InsTimeUtil::SECONDS_PER_DAY;
996 return std::chrono::duration<long double>(diffSec);
997 }
998
1002 constexpr InsTime& operator+=(const std::chrono::duration<long double>& duration)
1003 {
1004 auto duration_mjd_frac = std::chrono::duration<long double, std::ratio<InsTimeUtil::SECONDS_PER_DAY>>(duration).count();
1005 this->_mjd = InsTime_MJD(this->_mjd.mjd_day,
1006 this->_mjd.mjd_frac + duration_mjd_frac);
1007 return *this;
1008 }
1009
1013 constexpr InsTime& operator-=(const std::chrono::duration<long double>& duration)
1014 {
1015 auto duration_mjd_frac = std::chrono::duration<long double, std::ratio<InsTimeUtil::SECONDS_PER_DAY>>(duration).count();
1016 this->_mjd = InsTime_MJD(this->_mjd.mjd_day,
1017 this->_mjd.mjd_frac - duration_mjd_frac);
1018 return *this;
1019 }
1020
1025 constexpr friend InsTime operator+(const InsTime& time, const std::chrono::duration<long double>& duration)
1026 {
1027 return InsTime(time) += duration;
1028 }
1029
1034 constexpr friend InsTime operator-(const InsTime& time, const std::chrono::duration<long double>& duration)
1035 {
1036 return InsTime(time) -= duration;
1037 }
1038
1039 /* ---------------------------- Utility Functions --------------------------- */
1040
1042 explicit operator std::string() const;
1043
1045 [[nodiscard]] constexpr bool empty() const
1046 {
1047 return _mjd.mjd_day == 0 && _mjd.mjd_frac == 0.0L;
1048 }
1049
1051 void reset()
1052 {
1053 _mjd.mjd_day = 0;
1054 _mjd.mjd_frac = 0.0L;
1055 }
1056
1060 void MakeTimeFromGloOrbit(double UTC_sec)
1061 {
1062 auto ymdhms = toYMDHMS();
1063 // difference between toe (OBRIT-0 last element) and toc (ORBIT-0 first element) in seconds
1064 long double diff = gcem::fmod(static_cast<long double>(UTC_sec), InsTimeUtil::SECONDS_PER_DAY)
1065 - (ymdhms.hour * InsTimeUtil::SECONDS_PER_HOUR
1066 + ymdhms.min * InsTimeUtil::SECONDS_PER_MINUTE
1067 + ymdhms.sec);
1068 // std::cout << "orbit diff " << diff << "\n";
1069 *this += std::chrono::duration<long double>(diff);
1070 }
1071
1074 [[nodiscard]] constexpr int differenceToUTC(TimeSystem timesys) const
1075 {
1076 switch (TimeSystem_(timesys))
1077 {
1078 case GPST: // = GPS Time (UTC + leap_seconds)
1079 return this->leapGps2UTC();
1080 case GLNT: // = GLONASS Time (UTC+ 3h)
1082 case GST: // = GALILEO Time (~ GPS) (UTC = GST - 18) is synchronized with TAI with a nominal offset below 50 ns
1083 return this->leapGps2UTC();
1084 case QZSST:
1085 return 0; // TODO: Implement QZSST<->UTC time difference
1086 case IRNSST:
1087 return 0; // TODO: Implement IRNSST<->UTC time difference
1088 case BDT: // = BeiDou Time (UTC) is synchronized with UTC within 100 ns<
1089 return this->leapGps2UTC() - 14;
1090 case UTC:
1091 case TimeSys_None:
1092 return 0;
1093 }
1094 return 0;
1095 }
1096
1097 private:
1099 InsTime_MJD _mjd{};
1100};
1101
1106std::ostream& operator<<(std::ostream& os, const InsTime_MJD& mjd);
1111std::ostream& operator<<(std::ostream& os, const InsTime_JD& jd);
1116std::ostream& operator<<(std::ostream& os, const InsTime_GPSweekTow& gpsWeekTow);
1121std::ostream& operator<<(std::ostream& os, const InsTime_YMDHMS& ymdhms);
1126std::ostream& operator<<(std::ostream& os, const InsTime_YDoySod& yDoySod);
1131std::ostream& operator<<(std::ostream& os, const InsTime& insTime);
1132
1136void to_json(json& j, const InsTime& insTime);
1140void from_json(const json& j, InsTime& insTime);
1141
1142} // namespace NAV
1143
1144namespace std
1145{
1147template<>
1148struct hash<NAV::InsTime>
1149{
1152 std::size_t operator()(const NAV::InsTime& t) const
1153 {
1154 auto hash1 = std::hash<int32_t>{}(t.toMJD().mjd_day);
1155 auto hash2 = std::hash<long double>{}(t.toMJD().mjd_frac);
1156
1157 return hash1 | (hash2 << 32);
1158 }
1159};
1160} // namespace std
1161
1162#ifndef DOXYGEN_IGNORE
1163
1164template<>
1165struct fmt::formatter<NAV::InsTime_MJD> : ostream_formatter
1166{};
1167template<>
1168struct fmt::formatter<NAV::InsTime_JD> : ostream_formatter
1169{};
1170template<>
1171struct fmt::formatter<NAV::InsTime_GPSweekTow> : ostream_formatter
1172{};
1173template<>
1174struct fmt::formatter<NAV::InsTime_YMDHMS> : ostream_formatter
1175{};
1176template<>
1177struct fmt::formatter<NAV::InsTime_YDoySod> : ostream_formatter
1178{};
1179template<>
1180struct fmt::formatter<NAV::InsTime> : ostream_formatter
1181{};
1182
1183#endif
std::ostream & operator<<(std::ostream &os, const NAV::CycleSlipDetector::Result &obj)
Stream insertion operator overload.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Simple Math functions.
Time System defintions.
TimeSystem_
List of all time systems.
Definition TimeSystem.hpp:26
@ IRNSST
Indian Regional Navigation Satellite System Time.
Definition TimeSystem.hpp:34
@ GST
Galileo System Time.
Definition TimeSystem.hpp:31
@ BDT
BeiDou Time.
Definition TimeSystem.hpp:32
@ GLNT
GLONASS Time (GLONASST)
Definition TimeSystem.hpp:30
@ TimeSys_None
No Time system.
Definition TimeSystem.hpp:27
@ QZSST
Quasi-Zenith Satellite System Time.
Definition TimeSystem.hpp:33
@ GPST
GPS Time.
Definition TimeSystem.hpp:29
@ UTC
Coordinated Universal Time.
Definition TimeSystem.hpp:28
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
constexpr InsTime(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, long double sec, TimeSystem timesys=UTC)
Constructor.
Definition InsTime.hpp:770
constexpr InsTime(const InsTime &)=default
Copy constructor.
constexpr InsTime()=default
Default Constructor.
constexpr InsTime_JD toJD(TimeSystem timesys=UTC) const
Converts this time object into a different format.
Definition InsTime.hpp:798
constexpr bool operator>=(const InsTime &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:975
constexpr InsTime & operator+=(const std::chrono::duration< long double > &duration)
Adds a duration to this time point.
Definition InsTime.hpp:1002
constexpr InsTime & operator=(InsTime &&)=default
Move assignment operator.
constexpr InsTime_YDoySod toYDoySod(TimeSystem timesys=UTC) const
Converts this time object into a different format.
Definition InsTime.hpp:860
constexpr InsTime & operator=(const InsTime &)=default
Copy assignment operator.
constexpr InsTime(int32_t gpsCycle, int32_t gpsWeek, long double tow, TimeSystem timesys=GPST)
Constructor.
Definition InsTime.hpp:759
constexpr int differenceToUTC(TimeSystem timesys) const
Returns the time difference in [s] of a time system and UTC.
Definition InsTime.hpp:1074
constexpr InsTime_GPSweekTow toGPSweekTow(TimeSystem timesys=GPST) const
Converts this time object into a different format.
Definition InsTime.hpp:811
constexpr friend std::chrono::duration< long double > operator-(const InsTime &lhs, const InsTime &rhs)
Substracts 2 points in time.
Definition InsTime.hpp:991
constexpr InsTime(const InsTime_GPSweekTow &gpsWeekTow, TimeSystem timesys=GPST)
Constructor.
Definition InsTime.hpp:695
constexpr InsTime & operator-=(const std::chrono::duration< long double > &duration)
Substracts a duration to this time point.
Definition InsTime.hpp:1013
constexpr InsTime(const InsTime_YDoySod &yearDoySod, TimeSystem timesys=UTC)
Constructor.
Definition InsTime.hpp:736
constexpr friend InsTime operator-(const InsTime &time, const std::chrono::duration< long double > &duration)
Substracts a duration from a time point.
Definition InsTime.hpp:1034
constexpr bool operator<(const InsTime &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:979
static constexpr uint16_t leapGps2UTC(const InsTime_JD &jd)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime_JD object.
Definition InsTime.hpp:938
constexpr InsTime_YMDHMS toYMDHMS(TimeSystem timesys=UTC, int digits=-1) const
Converts this time object into a different format.
Definition InsTime.hpp:828
constexpr bool operator>(const InsTime &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:983
static constexpr uint16_t leapGps2UTC(const InsTime_GPSweekTow &gpsWeekTow)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime_GPSweekTow object.
Definition InsTime.hpp:914
~InsTime()=default
Destructor.
constexpr uint16_t leapGps2UTC() const
Returns the current number of leap seconds (offset GPST to UTC)
Definition InsTime.hpp:898
constexpr InsTime_MJD toMJD(TimeSystem timesys=UTC) const
Converts this time object into a different format.
Definition InsTime.hpp:789
constexpr InsTime(const InsTime_MJD &mjd, TimeSystem timesys=UTC)
Constructor.
Definition InsTime.hpp:677
constexpr bool empty() const
Checks if the Time object has a value.
Definition InsTime.hpp:1045
static constexpr uint16_t leapGps2UTC(const InsTime &insTime)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime object.
Definition InsTime.hpp:906
static constexpr uint16_t leapGps2UTC(const InsTime_YDoySod &yearDoySod)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime_YDoySod object.
Definition InsTime.hpp:922
constexpr InsTime(const InsTime_YMDHMS &yearMonthDayHMS, TimeSystem timesys=UTC)
Constructor.
Definition InsTime.hpp:710
constexpr bool operator!=(const InsTime &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:967
constexpr friend InsTime operator+(const InsTime &time, const std::chrono::duration< long double > &duration)
Adds a duration to a time point.
Definition InsTime.hpp:1025
void MakeTimeFromGloOrbit(double UTC_sec)
Adds the difference [seconds] between toe (OBRIT-0 last element) and toc (ORBIT-0 first element) to t...
Definition InsTime.hpp:1060
constexpr InsTime toFullDay() const
Returns the current time rounded/cutted to a full day (changes time to 0:0:0h UTC of current day)
Definition InsTime.hpp:882
constexpr long double toUnixTime() const
Converts this time object into a UNIX timestamp in [s].
Definition InsTime.hpp:888
constexpr bool operator<=(const InsTime &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:971
constexpr bool operator==(const InsTime &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:963
void reset()
Resets the InsTime object.
Definition InsTime.hpp:1051
constexpr bool isLeapYear() const
Checks if the current time is a leap year.
Definition InsTime.hpp:953
static constexpr uint16_t leapGps2UTC(const InsTime_MJD &mjd_in)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime_MJD object.
Definition InsTime.hpp:946
constexpr InsTime(const InsTime_JD &jd, TimeSystem timesys=UTC)
Constructor.
Definition InsTime.hpp:686
constexpr InsTime(InsTime &&)=default
Move constructor.
static constexpr uint16_t leapGps2UTC(const InsTime_YMDHMS &yearMonthDayHMS)
Returns the number of leap seconds (offset GPST to UTC) for the provided InsTime_YMDHMS object.
Definition InsTime.hpp:930
Time System defintions.
Definition TimeSystem.hpp:39
constexpr long double EPSILON
Definition InsTime.hpp:66
constexpr int32_t MINUTES_PER_HOUR
Minutes / Hour.
Definition InsTime.hpp:54
constexpr long double DIFF_MJD_TO_JD_FRAC
Difference of the fraction between MJD and JD.
Definition InsTime.hpp:47
constexpr int32_t MINUTES_PER_DAY
Minutes / Day.
Definition InsTime.hpp:55
constexpr int32_t SECONDS_PER_DAY
Seconds / Day.
Definition InsTime.hpp:59
constexpr int32_t daysInMonth(int32_t month, int32_t year)
Returns the number of days in the specified month of the year.
Definition InsTime.hpp:104
constexpr int32_t END_OF_THE_CENTURY_MJD
Modified Julian Date of the end of the century (15.01.2954)
Definition InsTime.hpp:40
constexpr int32_t SECONDS_PER_WEEK
Seconds / Week.
Definition InsTime.hpp:60
constexpr int32_t DIFF_TO_6_1_1980_MJD
06.01.1980 in Modified Julian Date
Definition InsTime.hpp:42
constexpr int32_t DAYS_PER_WEEK
Days / Week.
Definition InsTime.hpp:51
constexpr bool isLeapYear(int32_t year)
Returns true if the provided year is a leap year, false otherwise.
Definition InsTime.hpp:95
constexpr int32_t MONTHS_PER_YEAR
Months / Year.
Definition InsTime.hpp:49
constexpr int32_t DAYS_PER_YEAR
Days / Year.
Definition InsTime.hpp:50
constexpr int32_t DIFF_MJD_TO_JD_DAYS
Difference of the days between MJD and JD.
Definition InsTime.hpp:46
constexpr int32_t HOURS_PER_DAY
Hours / Day.
Definition InsTime.hpp:52
constexpr int32_t HOURS_PER_WEEK
Hours / Week.
Definition InsTime.hpp:53
constexpr int32_t MINUTES_PER_WEEK
Minutes / Week.
Definition InsTime.hpp:56
constexpr std::array< int32_t, 20 > GPS_LEAP_SEC_MJD
Maps GPS leap seconds to a time: array<mjd_day>, index + 1 is amount of leap seconds.
Definition InsTime.hpp:69
constexpr int32_t WEEKS_PER_GPS_CYCLE
Weeks per GPS cycle.
Definition InsTime.hpp:41
constexpr int32_t DIFF_BDT_WEEK_TO_GPST_WEEK
BeiDou starts zero at 1-Jan-2006 and GPS starts 6-Jan-1980.
Definition InsTime.hpp:44
constexpr int32_t SECONDS_PER_HOUR
Seconds / Hour.
Definition InsTime.hpp:58
constexpr int32_t SECONDS_PER_MINUTE
Seconds / Minute.
Definition InsTime.hpp:57
constexpr int32_t DIFF_TO_1_1_1970_MJD
01.01.1970 00:00:00 UTC in Modified Julian Date (UNIX epoch)
Definition InsTime.hpp:43
GPS week and time of week in GPS standard time [GPST].
Definition InsTime.hpp:326
constexpr bool operator>=(const InsTime_GPSweekTow &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:394
constexpr bool operator!=(const InsTime_GPSweekTow &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:380
int32_t gpsCycle
Contains GPS cycle in GPS standard time [GPST].
Definition InsTime.hpp:327
constexpr bool operator<=(const InsTime_GPSweekTow &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:387
int32_t gpsWeek
Contains GPS week in GPS standard time [GPST].
Definition InsTime.hpp:328
constexpr InsTime_GPSweekTow(int32_t gpsCycle, int32_t gpsWeek, long double tow)
Constructor.
Definition InsTime.hpp:335
constexpr bool operator<(const InsTime_GPSweekTow &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:401
constexpr bool operator>(const InsTime_GPSweekTow &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:411
constexpr bool operator==(const InsTime_GPSweekTow &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:364
long double tow
Contains GPS time of week in seconds in GPS standard time [GPST].
Definition InsTime.hpp:329
Julien Date [UTC].
Definition InsTime.hpp:243
int32_t jd_day
Full days since 1. January −4712 [UTC].
Definition InsTime.hpp:244
constexpr bool operator<(const InsTime_JD &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:307
constexpr InsTime_JD(int32_t jd_day, long double jd_frac)
Constructor.
Definition InsTime.hpp:250
constexpr bool operator>=(const InsTime_JD &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:300
constexpr bool operator>(const InsTime_JD &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:315
long double jd_frac
Decimal fractions of a day of the Julien Date [UTC].
Definition InsTime.hpp:245
constexpr bool operator<=(const InsTime_JD &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:293
constexpr bool operator!=(const InsTime_JD &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:286
constexpr bool operator==(const InsTime_JD &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:268
Modified Julien Date [UTC].
Definition InsTime.hpp:157
constexpr bool operator>=(const InsTime_MJD &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:217
constexpr bool operator!=(const InsTime_MJD &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:203
long double mjd_frac
Decimal fractions of a day of the Modified Julien Date [UTC].
Definition InsTime.hpp:159
constexpr bool operator>(const InsTime_MJD &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:232
constexpr InsTime_MJD(int32_t mjd_day, long double mjd_frac)
Constructor.
Definition InsTime.hpp:167
constexpr bool operator==(const InsTime_MJD &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:185
constexpr bool operator<=(const InsTime_MJD &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:210
constexpr bool operator<(const InsTime_MJD &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:224
constexpr InsTime_MJD()=default
Default constructor.
int32_t mjd_day
Full days since 17. November 1858 [UTC].
Definition InsTime.hpp:158
GPS year and day of year in GPS standard time [GPST].
Definition InsTime.hpp:570
long double sod
Contains second of day in GPS standard time [GPST].
Definition InsTime.hpp:573
constexpr bool operator<(const InsTime_YDoySod &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:646
int32_t year
Contains year in GPS standard time [GPST].
Definition InsTime.hpp:571
constexpr bool operator!=(const InsTime_YDoySod &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:625
constexpr bool operator>(const InsTime_YDoySod &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:656
constexpr bool operator==(const InsTime_YDoySod &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:608
int32_t doy
Contains day of year in GPS standard time [GPST].
Definition InsTime.hpp:572
constexpr bool operator<=(const InsTime_YDoySod &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:632
constexpr bool operator>=(const InsTime_YDoySod &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:639
constexpr InsTime_YDoySod(int32_t year, int32_t doy, long double sod)
Constructor.
Definition InsTime.hpp:579
Universal Time Coordinated [UTC].
Definition InsTime.hpp:422
int32_t min
Contains minute in Universal Time Coordinated [UTC].
Definition InsTime.hpp:427
constexpr bool operator>=(const InsTime_YMDHMS &rhs) const
Greater or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:539
int32_t year
Contains year in Universal Time Coordinated [UTC].
Definition InsTime.hpp:423
constexpr bool operator<(const InsTime_YMDHMS &rhs) const
Smaller comparison operator (takes double precision into account)
Definition InsTime.hpp:546
constexpr InsTime_YMDHMS(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, long double sec, int digits=-1)
Constructor.
Definition InsTime.hpp:438
constexpr bool operator==(const InsTime_YMDHMS &rhs) const
Equal comparison operator (takes double precision into account)
Definition InsTime.hpp:508
constexpr bool operator!=(const InsTime_YMDHMS &rhs) const
Inequal comparison operator (takes double precision into account)
Definition InsTime.hpp:525
long double sec
Contains second in Universal Time Coordinated [UTC].
Definition InsTime.hpp:428
int32_t month
Contains month in Universal Time Coordinated [UTC].
Definition InsTime.hpp:424
constexpr bool operator>(const InsTime_YMDHMS &rhs) const
Greater comparison operator (takes double precision into account)
Definition InsTime.hpp:559
int32_t hour
Contains hour in Universal Time Coordinated [UTC].
Definition InsTime.hpp:426
int32_t day
Contains day in Universal Time Coordinated [UTC].
Definition InsTime.hpp:425
constexpr bool operator<=(const InsTime_YMDHMS &rhs) const
Smaller or equal comparison operator (takes double precision into account)
Definition InsTime.hpp:532
std::size_t operator()(const NAV::InsTime &t) const
Hash function for InsTime.
Definition InsTime.hpp:1152