OffsetModel.java

  1. /* Copyright 2002-2025 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. import java.io.Serializable;

  19. /** TAI UTC offset model.
  20.  * @see UTCTAIOffsetsLoader
  21.  * @author Luc Maisonobe
  22.  * @since 7.1
  23.  */
  24. public class OffsetModel implements Serializable {

  25.     /** Serializable UID. */
  26.     private static final long serialVersionUID = 20240721L;

  27.     /** Date of the offset start. */
  28.     private final DateComponents start;

  29.     /** Reference date of the linear model as a modified julian day. */
  30.     private final int mjdRef;

  31.     /** Offset at reference date in seconds (TAI minus UTC). */
  32.     private final TimeOffset offset;

  33.     /** Offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC). */
  34.     private final int slope;

  35.     /** Constructor for a linear offset model.
  36.      * <p>
  37.      * These models were used prior to 1972.
  38.      * </p>
  39.      * @param start date of the offset start
  40.      * @param mjdRef reference date of the linear model as a modified julian day
  41.      * @param offset offset at reference date in seconds (TAI minus UTC)
  42.      * @param slope offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC)
  43.      */
  44.     public OffsetModel(final DateComponents start,
  45.                        final int mjdRef, final TimeOffset offset, final int slope) {
  46.         this.start  = start;
  47.         this.mjdRef = mjdRef;
  48.         this.offset = offset;
  49.         this.slope  = slope;
  50.     }

  51.     /** Constructor for a constant offset model.
  52.      * <p>
  53.      * These models are used since 1972.
  54.      * </p>
  55.      * @param start date of the offset start
  56.      * @param offset offset at reference date in seconds (TAI minus UTC)
  57.      */
  58.     public OffsetModel(final DateComponents start, final int offset) {
  59.         this(start, 41317, new TimeOffset(offset, 0L), 0);
  60.     }

  61.     /** Get the date of the offset start.
  62.      * @return date of the offset start
  63.      */
  64.     public DateComponents getStart() {
  65.         return start;
  66.     }

  67.     /** Get the reference date of the linear model as a modified julian day.
  68.      * @return reference date of the linear model as a modified julian day
  69.      */
  70.     public int getMJDRef() {
  71.         return mjdRef;
  72.     }

  73.     /** Offset at reference date in seconds (TAI minus UTC).
  74.      * @return offset at reference date in seconds (TAI minus UTC)
  75.      */
  76.     public TimeOffset getOffset() {
  77.         return offset;
  78.     }

  79.     /** Offset slope in nanoseconds per UTC second (TAI minus UTC / dUTC).
  80.      * @return offset slope in nanoseconds per UTC second  (TAI minus UTC / dUTC)
  81.      */
  82.     public int getSlope() {
  83.         return slope;
  84.     }

  85. }