1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk is free software; you can redistribute it and/or modify
6 //  it under the terms of the GNU Lesser General Public License as published
7 //  by the Free Software Foundation; either version 3.0 of the License, or
8 //  any later version.
9 //
10 //  The GPSTk is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU Lesser General Public License for more details.
14 //
15 //  You should have received a copy of the GNU Lesser General Public
16 //  License along with GPSTk; if not, write to the Free Software Foundation,
17 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 //  This software was developed by Applied Research Laboratories at the
20 //  University of Texas at Austin.
21 //  Copyright 2004-2020, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 //  This software was developed by Applied Research Laboratories at the
28 //  University of Texas at Austin, under contract to an agency or agencies
29 //  within the U.S. Department of Defense. The U.S. Government retains all
30 //  rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 //  Pursuant to DoD Directive 523024
33 //
34 //  DISTRIBUTION STATEMENT A: This software has been approved for public
35 //                            release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 /// @file TimeConstants.hpp Define constants related to time, both in
40 ///    general and for the different GNSS.
41 
42 #ifndef GPSTK_TIMECONSTANTS_HPP
43 #define GPSTK_TIMECONSTANTS_HPP
44 
45 namespace gpstk
46 {
47       /// @ingroup TimeHandling
48       //@{
49 
50       /// Add this offset to convert Modified Julian Date to Julian Date.
51    const double MJD_TO_JD = 2400000.5;
52       /// 'Julian day' offset from MJD
53    const long MJD_JDAY = 2400001L;
54       /// Modified Julian Date of UNIX epoch (Jan. 1, 1970).
55    const long UNIX_MJD = 40587L;
56 
57       /// Seconds per half week.
58    const long HALFWEEK = 302400L;
59       /// Seconds per whole week.
60    const long FULLWEEK = 604800L;
61 
62       /// Seconds per day.
63    const long SEC_PER_DAY = 86400L;
64       /// Days per second.
65    const double DAY_PER_SEC = 1.0/SEC_PER_DAY;
66 
67       /// Milliseconds in a second.
68    const long MS_PER_SEC = 1000L;
69       /// Seconds per millisecond.
70    const double SEC_PER_MS = 1.0/MS_PER_SEC;
71 
72       /// Milliseconds in a day.
73    const long MS_PER_DAY = MS_PER_SEC * SEC_PER_DAY;
74       /// Days per milliseconds.
75    const double DAY_PER_MS = 1.0/MS_PER_DAY;
76 
77    // system-specific constants
78 
79    // GPS -------------------------------------------
80       /// 'Julian day' of GPS epoch (Jan. 6, 1980).
81    const double GPS_EPOCH_JD = 2444244.5;
82       /// Modified Julian Date of GPS epoch (Jan. 6, 1980).
83    const long GPS_EPOCH_MJD = 44244L;
84       /// Weeks per GPS Epoch
85    const long GPS_WEEK_PER_EPOCH = 1024L;
86 
87       /// Zcounts in a  day.
88    const long ZCOUNT_PER_DAY = 57600L;
89       /// Days in a Zcount
90    const double DAY_PER_ZCOUNT = 1.0/ZCOUNT_PER_DAY;
91       /// Zcounts in a week.
92    const long ZCOUNT_PER_WEEK = 403200L;
93       /// Weeks in a Zcount.
94    const double WEEK_PER_ZCOUNT = 1.0/ZCOUNT_PER_WEEK;
95       /// Z-counts per minute.
96    const long ZCOUNT_PER_MINUTE = 40;
97       /// Z-counts per hour.
98    const long ZCOUNT_PER_HOUR = 2400;
99 
100    // GAL -------------------------------------------
101       /// 'Julian day' of GAL epoch (Aug 22 1999)
102    const double GAL_EPOCH_JD = 2451412.5;
103       /// Modified Julian Date of GAL epoch (Aug 22 1999)
104    const long GAL_EPOCH_MJD = 51412L;
105       /// Weeks per GAL Epoch
106    const long GAL_WEEK_PER_EPOCH = 4096L;
107 
108    // QZS -------------------------------------------
109       /// 'Julian day' of QZS epoch (Jan. 1, 1980).
110    const double QZS_EPOCH_JD = 2444244.5;
111       /// Modified Julian Date of QZS epoch (Jan. 1, 1980).
112    const long QZS_EPOCH_MJD = 44244L;
113       /// Weeks per QZS Epoch
114    const long QZS_WEEK_PER_EPOCH = 65535L;         // effectively no rollover
115 
116    // BDS -------------------------------------------
117       /// 'Julian day' of BDS epoch (Jan. 1, 2006).
118    const double BDS_EPOCH_JD = 2453736.5;
119       /// Modified Julian Date of BDS epoch (Jan. 1, 2006).
120    const long BDS_EPOCH_MJD = 53736L;
121       /// Weeks per BDS Epoch
122    const long BDS_WEEK_PER_EPOCH = 8192L;
123 
124    // IRN -------------------------------------------
125       /// 'Julian day' of IRN epoch (Aug 22, 1999).
126    const double IRN_EPOCH_JD = 2451412.5;
127       /// Modified Julian Date of BDS epoch (Aug 22, 1999).
128    const long IRN_EPOCH_MJD = 51412L;
129       /// Weeks per BDS Epoch
130    const long IRN_WEEK_PER_EPOCH = 1024L;
131 
132 
133       //@}
134 
135 } // namespace
136 
137 #endif // GPSTK_TIMECONSTANTS_HPP
138