Program Listing for File time_utils.h

Return to documentation for file (environment/plasma/env/time_utils.h)

#pragma once

#include <array>

namespace pecsim {

  struct DateTime {
    int year;
    int doy;
    int hour;
    int min;
    double sec;
  };

  void doy_to_mmdd(int year, int doy, int& mm, int& dd);

  void mmdd_to_doy(int year, int mm, int dd, int& doy);

  std::array<int, 2> datetime_to_itime(DateTime datetime);

  /*
   * @brief Convert itime array to DateTime object.
   *
   * @param itime The itime array, where itime[0] is year and day of year,
   *              and itime[1] is milliseconds of the day.
   * @return DateTime The DateTime object.
   */
  DateTime itime_to_datetime(const std::array<int, 2>& itime);

  double datetime_to_mjd(const DateTime& datetime);

  DateTime mjd_to_datetime(double mjd);

  double long_to_lt(double along);

  double lt_to_long(double amlt);

  double tj2000_to_mjd(double t_j2000);

  double mjd_to_tj2000(double mjd);

  double gregorian_to_mjd(int year, int month, int day, int hour, int min, double sec);

}  // namespace pecsim