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 * 00084 * \return error status: CTA_OK if successful 00085 */ 00086 CTAEXPORT int CTA_DateTime_ModifiedJulianToJulian(double mjd, double *jd); 00087 00088 /** \brief Gregorian calendar date from Julian day number 00089 * 00090 * \param jd I Julian day number 00091 * \param year O Year 00092 * \param month O Month 00093 * \param day O Day 00094 * \param hour O Hour 00095 * \param minute O Minute 00096 * \param second O Second 00097 * \param jd O Julian day number 00098 * 00099 * \return error status: CTA_OK if successful 00100 */ 00101 CTAEXPORT int CTA_DateTime_JulianToGregorian(double jd, int *year, int *month, int *day, int *hour, int *minute, int *second); 00102 00103 /** \brief Gregorian calendar date from Modified Julian day number 00104 * 00105 * \param mjd I Modified Julian day number 00106 * \param year O Year 00107 * \param month O Month 00108 * \param day O Day 00109 * \param hour O Hour 00110 * \param minute O Minute 00111 * \param second O Second 00112 * 00113 * \return error status: CTA_OK if successful 00114 */ 00115 CTAEXPORT int CTA_DateTime_ModifiedJulianToGregorian(double mjd, int *year, int *month, int *day, int *hour, int *minute, int *second); 00116 00117 #ifdef __cplusplus 00118 } 00119 #endif 00120 00121 #endif