00001 /* 00002 COSTA: Problem solving environment for data assimilation 00003 Copyright (C) 2007 Johan Ansink 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 /** 00021 \file cta_datetime.h 00022 \brief Interface description of the default COSTA datetime component. 00023 00024 A datetime object describes a date and time object 00025 */ 00026 00027 #ifndef CTA_DATETIME_H 00028 #define CTA_DATETIME_H 00029 00030 #include <time.h> 00031 #include "cta_handles.h" 00032 #include "cta_datatypes.h" 00033 #include "cta_system.h" 00034 00035 #define MJDREF 2400000.5 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 /** \brief Julian day number from Gregorian date. 00042 * 00043 * \param year I Year 00044 * \param month I Month 00045 * \param day I Day 00046 * \param hour I Hour 00047 * \param minute I Minute 00048 * \param second I Second 00049 * \param jd O Julian day number 00050 * 00051 * \return error status: CTA_OK if successful 00052 */ 00053 CTAEXPORT int CTA_DateTime_GregorianToJulian(int year, int month, int day, int hour, int minute, int second, double *jd); 00054 00055 /** \brief Modified Julian day number from Gregorian date. 00056 * 00057 * \param year I Year 00058 * \param month I Month 00059 * \param day I Day 00060 * \param hour I Hour 00061 * \param minute I Minute 00062 * \param second I Second 00063 * \param mjd O Modified Julian day number 00064 * 00065 * \return error status: CTA_OK if successful 00066 */ 00067 CTAEXPORT int CTA_DateTime_GregorianToModifiedJulian(int year, int month, int day, int hour, int minute, int second, double *mjd); 00068 00069 /** \brief Convert days into hours, minutes, and seconds. 00070 * 00071 * \param days I Year 00072 * \param hour O Hour 00073 * \param minute O Minute 00074 * \param second O Second 00075 * 00076 * \return error status: CTA_OK if successful 00077 */ 00078 CTAEXPORT int CTA_DateTime_DaysToHMS (double days, int *hour, int *minute, int *second); 00079 00080 /** \brief Julian day number from Modified Julian day number 00081 * 00082 * \param mjd I Modified Julian day number 00083 * \param jd O Julian day number 00084 * 00085 * \return error status: CTA_OK if successful 00086 */ 00087 CTAEXPORT int CTA_DateTime_ModifiedJulianToJulian(double mjd, double *jd); 00088 00089 /** \brief Gregorian calendar date from Julian day number 00090 * 00091 * \param jd I Julian day number 00092 * \param year O Year 00093 * \param month O Month 00094 * \param day O Day 00095 * \param hour O Hour 00096 * \param minute O Minute 00097 * \param second O Second 00098 * \param jd O Julian day number 00099 * 00100 * \return error status: CTA_OK if successful 00101 */ 00102 CTAEXPORT int CTA_DateTime_JulianToGregorian(double jd, int *year, int *month, int *day, int *hour, int *minute, int *second); 00103 00104 /** \brief Gregorian calendar date from Modified Julian day number 00105 * 00106 * \param mjd I Modified Julian day number 00107 * \param year O Year 00108 * \param month O Month 00109 * \param day O Day 00110 * \param hour O Hour 00111 * \param minute O Minute 00112 * \param second O Second 00113 * 00114 * \return error status: CTA_OK if successful 00115 */ 00116 CTAEXPORT int CTA_DateTime_ModifiedJulianToGregorian(double mjd, int *year, int *month, int *day, int *hour, int *minute, int *second); 00117 00118 #ifdef __cplusplus 00119 } 00120 #endif 00121 00122 #endif