1 /* Copyright 2002-2026 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.time;
18
19 import java.io.Serial;
20 import java.io.Serializable;
21
22 /** TAI UTC offset model.
23 * @see UTCTAIOffsetsLoader
24 * @author Luc Maisonobe
25 * @since 7.1
26 */
27 public class OffsetModel implements Serializable {
28
29 /** Serializable UID. */
30 @Serial
31 private static final long serialVersionUID = 20240721L;
32
33 /** Date of the offset start. */
34 private final DateComponents start;
35
36 /** Reference date of the linear model as a modified julian day. */
37 private final int mjdRef;
38
39 /** Offset at reference date in seconds (TAI minus UTC). */
40 private final TimeOffset offset;
41
42 /** Offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC). */
43 private final int slope;
44
45 /** Constructor for a linear offset model.
46 * <p>
47 * These models were used prior to 1972.
48 * </p>
49 * @param start date of the offset start
50 * @param mjdRef reference date of the linear model as a modified julian day
51 * @param offset offset at reference date in seconds (TAI minus UTC)
52 * @param slope offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC)
53 */
54 public OffsetModel(final DateComponents start,
55 final int mjdRef, final TimeOffset offset, final int slope) {
56 this.start = start;
57 this.mjdRef = mjdRef;
58 this.offset = offset;
59 this.slope = slope;
60 }
61
62 /** Constructor for a constant offset model.
63 * <p>
64 * These models are used since 1972.
65 * </p>
66 * @param start date of the offset start
67 * @param offset offset at reference date in seconds (TAI minus UTC)
68 */
69 public OffsetModel(final DateComponents start, final int offset) {
70 this(start, 41317, new TimeOffset(offset, 0L), 0);
71 }
72
73 /** Get the date of the offset start.
74 * @return date of the offset start
75 */
76 public DateComponents getStart() {
77 return start;
78 }
79
80 /** Get the reference date of the linear model as a modified julian day.
81 * @return reference date of the linear model as a modified julian day
82 */
83 public int getMJDRef() {
84 return mjdRef;
85 }
86
87 /** Offset at reference date in seconds (TAI minus UTC).
88 * @return offset at reference date in seconds (TAI minus UTC)
89 */
90 public TimeOffset getOffset() {
91 return offset;
92 }
93
94 /** Offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC).
95 * @return offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC)
96 */
97 public int getSlope() {
98 return slope;
99 }
100
101 }