IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1247


Ignore:
Timestamp:
Jul 20, 2004, 3:29:33 PM (22 years ago)
Author:
harman
Message:

Added more time functions

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psTime.c

    r1223 r1247  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-07-15 19:02:13 $
     14 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-07-21 01:29:33 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424
    2525#include <stdio.h>
     26#include <stdlib.h>
     27#include <string.h>
    2628
    2729#include "psTime.h"
    2830#include "psError.h"
     31#define PS_ALLOW_MALLOC
     32#include "psMemory.h"
    2933
    3034/******************************************************************************/
     
    3236/******************************************************************************/
    3337
    34 // Number of available leapsecond updates
    35 #define NUM_LEAPSECOND_UPDATES 23
     38/** Preprocessor macro to generate error for negative time in struct */
     39#define CHECK_NEGATIVE_TIME_STRUCT(NAME,RETURN)                                                              \
     40if(NAME.tv_sec < 0) {                                                                                        \
     41    psError(__func__,"Negative seconds are not allowed: %ld", NAME.tv_sec);                                  \
     42    return RETURN;                                                                                           \
     43} else if(NAME.tv_usec<0) {                                                                                  \
     44    psError(__func__,"Negative microseconds are not allowed: %ld", NAME.tv_usec);                            \
     45    return RETURN;                                                                                           \
     46}
     47
     48/** Preprocessor macro to generate error for negative time */
     49#define CHECK_NEGATIVE_TIME(NAME,RETURN)                                                                     \
     50if(NAME < 0.0) {                                                                                             \
     51    psError(__func__,"Negative time is not allowed: %f", NAME);                                              \
     52    return RETURN;                                                                                           \
     53}                                                                                                            \
    3654
    3755/******************************************************************************/
     
    5573the psTimeGetTime() function to calculate TAI time from  UTC time.
    5674 
    57  1972 JAN  1 =JD 2441317.5  TAI-UTC= 10.0
    58  1972 JUL  1 =JD 2441499.5  TAI-UTC= 11.0
    59  1973 JAN  1 =JD 2441683.5  TAI-UTC= 12.0
    60  1974 JAN  1 =JD 2442048.5  TAI-UTC= 13.0
    61  1975 JAN  1 =JD 2442413.5  TAI-UTC= 14.0
    62  1976 JAN  1 =JD 2442778.5  TAI-UTC= 15.0
    63  1977 JAN  1 =JD 2443144.5  TAI-UTC= 16.0
    64  1978 JAN  1 =JD 2443509.5  TAI-UTC= 17.0
    65  1979 JAN  1 =JD 2443874.5  TAI-UTC= 18.0
    66  1980 JAN  1 =JD 2444239.5  TAI-UTC= 19.0
    67  1981 JUL  1 =JD 2444786.5  TAI-UTC= 20.0
    68  1982 JUL  1 =JD 2445151.5  TAI-UTC= 21.0
    69  1983 JUL  1 =JD 2445516.5  TAI-UTC= 22.0
    70  1985 JUL  1 =JD 2446247.5  TAI-UTC= 23.0
    71  1988 JAN  1 =JD 2447161.5  TAI-UTC= 24.0
    72  1990 JAN  1 =JD 2447892.5  TAI-UTC= 25.0
    73  1991 JAN  1 =JD 2448257.5  TAI-UTC= 26.0
    74  1992 JUL  1 =JD 2448804.5  TAI-UTC= 27.0
    75  1993 JUL  1 =JD 2449169.5  TAI-UTC= 28.0
    76  1994 JUL  1 =JD 2449534.5  TAI-UTC= 29.0
    77  1996 JAN  1 =JD 2450083.5  TAI-UTC= 30.0
    78  1997 JUL  1 =JD 2450630.5  TAI-UTC= 31.0
    79  1999 JAN  1 =JD 2451179.5  TAI-UTC= 32.0
     75 1972 JAN 1 = JD 2441317.5  TAI-UTC = 10.0
     76 1972 JUL 1 = JD 2441499.5  TAI-UTC = 11.0
     77 1973 JAN 1 = JD 2441683.5  TAI-UTC = 12.0
     78 1974 JAN 1 = JD 2442048.5  TAI-UTC = 13.0
     79 1975 JAN 1 = JD 2442413.5  TAI-UTC = 14.0
     80 1976 JAN 1 = JD 2442778.5  TAI-UTC = 15.0
     81 1977 JAN 1 = JD 2443144.5  TAI-UTC = 16.0
     82 1978 JAN 1 = JD 2443509.5  TAI-UTC = 17.0
     83 1979 JAN 1 = JD 2443874.5  TAI-UTC = 18.0
     84 1980 JAN 1 = JD 2444239.5  TAI-UTC = 19.0
     85 1981 JUL 1 = JD 2444786.5  TAI-UTC = 20.0
     86 1982 JUL 1 = JD 2445151.5  TAI-UTC = 21.0
     87 1983 JUL 1 = JD 2445516.5  TAI-UTC = 22.0
     88 1985 JUL 1 = JD 2446247.5  TAI-UTC = 23.0
     89 1988 JAN 1 = JD 2447161.5  TAI-UTC = 24.0
     90 1990 JAN 1 = JD 2447892.5  TAI-UTC = 25.0
     91 1991 JAN 1 = JD 2448257.5  TAI-UTC = 26.0
     92 1992 JUL 1 = JD 2448804.5  TAI-UTC = 27.0
     93 1993 JUL 1 = JD 2449169.5  TAI-UTC = 28.0
     94 1994 JUL 1 = JD 2449534.5  TAI-UTC = 29.0
     95 1996 JAN 1 = JD 2450083.5  TAI-UTC = 30.0
     96 1997 JUL 1 = JD 2450630.5  TAI-UTC = 31.0
     97 1999 JAN 1 = JD 2451179.5  TAI-UTC = 32.0
    8098*/
    8199
    82 // Julian date of leapsecond update and current total number of leapseconds for that date
     100// Table for Julian date of leapsecond update and current total number of leapseconds at that date
    83101static double leapseconds[NUM_LEAPSECOND_UPDATES][2] =
    84102    {
     
    135153    time.tv_usec = now.tv_usec;
    136154
    137     // Add last known leapseconds to UTC time to get TAI time
     155    // Add most current leapseconds value to UTC time to get TAI time
    138156    time.tv_sec += leapseconds[NUM_LEAPSECOND_UPDATES][1];
    139157
     
    143161char* psTimeToISO(psTime time)
    144162{
    145     struct tm *tm;
    146     tm = localtime (&time.tv_sec);
    147     printf("%d\n", tm->tm_sec);
    148     return NULL;
    149 }
     163    int ms = 0;
     164    char *timeString = NULL;
     165    char *tempString = NULL;
     166    struct tm *tmTime = NULL;
     167
     168    CHECK_NEGATIVE_TIME_STRUCT(time,NULL);
     169
     170    tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     171    timeString = psAlloc(MAX_TIME_STRING_LENGTH);
     172
     173    // Converts psTime to YYYY/MM/DD,HH:MM:SS.SSS in string form
     174    ms = time.tv_usec/1000;
     175    tmTime = gmtime(&time.tv_sec);
     176    if(!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y/%m/%d,%H:%M:%S", tmTime)) {
     177        psError(__func__, " : Line %d - Failed strftime conversion", __LINE__);
     178    }
     179
     180    if(snprintf(timeString,MAX_TIME_STRING_LENGTH,"%s.%3.3d", tempString, ms) < 0) {
     181        psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__);
     182    }
     183    psFree(tempString);
     184    free(tmTime);
     185
     186    return timeString;
     187}
     188
     189psTime psTimeToUTC(psTime time)
     190{
     191    int i = 0;
     192    double jd = 0.0;
     193    double ls = 0.0;
     194    double *jdTable = NULL;
     195    psTime outTime;
     196
     197    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
     198
     199    // Find leapseconds to subtract from psTime to get UTC time
     200    jd = psTimeToJD(time);
     201    jdTable = leapseconds[0];
     202    for(i=0; i<NUM_LEAPSECOND_UPDATES; i++, jdTable+=2) {
     203        if(jd > *jdTable) {
     204            ls = *(jdTable + 1);
     205        }
     206    }
     207
     208    outTime.tv_sec = time.tv_sec - ls;
     209    outTime.tv_usec = time.tv_usec;
     210
     211    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     212
     213    return outTime;
     214}
     215
     216double psTimeToMJD(psTime time)
     217{
     218    double mjd = 0.0;
     219
     220    CHECK_NEGATIVE_TIME_STRUCT(time,mjd);
     221
     222    // Modified Julian date conversion courtesy of Eugene Magnier
     223    mjd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 40587.0;
     224
     225    return mjd;
     226}
     227
     228double psTimeToJD(psTime time)
     229{
     230    double jd = 0.0;
     231
     232    CHECK_NEGATIVE_TIME_STRUCT(time,jd);
     233
     234    // Julian date conversion courtesy of Eugene Magnier
     235    jd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 2440587.5;
     236
     237    return jd;
     238}
     239
     240struct timeval psTimeToTimeval(psTime time)
     241{
     242    struct timeval timevalTime;
     243
     244    CHECK_NEGATIVE_TIME_STRUCT(time,timevalTime);
     245    timevalTime.tv_sec = time.tv_sec;
     246    timevalTime.tv_usec = time.tv_usec;
     247
     248    return timevalTime;
     249}
     250
     251struct tm* psTimeToTM(psTime time)
     252{
     253    struct tm *tmTime = NULL;
     254
     255    CHECK_NEGATIVE_TIME_STRUCT(time,tmTime);
     256    tmTime = gmtime(&time.tv_sec);
     257
     258    return tmTime;
     259}
     260
     261psTime psISOToTime(char *time)
     262{
     263    char tempString[MAX_TIME_STRING_LENGTH];
     264    int month;
     265    int day;
     266    int year;
     267    int hour;
     268    int minute;
     269    int second;
     270    int millisecond;
     271    struct tm tmTime;
     272    psTime outTime;
     273
     274    strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
     275
     276    // Convert YYYY/MM/DD,HH:MM:SS.SSS in string form to tm time
     277    year = atoi(strtok(tempString, "/"));
     278    if(year < 0) {
     279        psError(__func__,"Years less than 1900 not allowed. Value: %d", year);
     280    }
     281
     282    month = atoi(strtok(tempString, "/"));
     283    if(month<1 || month>12) {
     284        psError(__func__,"Month must have a value from 0 to 11. Value: %d", month);
     285    }
     286
     287    day = atoi(strtok(tempString, ","));
     288    if(day<1 || day>31) {
     289        psError(__func__,"Day must have a value from 1 to 31. Value: %d", day);
     290    }
     291
     292    hour = atoi(strtok(tempString, ":"));
     293    if(hour<0 || hour>23) {
     294        psError(__func__,"Hour must have a value from 0 to 23. Value: %d", hour);
     295    }
     296
     297    second = atoi(strtok(tempString, "."));
     298    if(second<0 || second>60) {
     299        psError(__func__,"Second must have a value from 0 to 59. Value: %d", second);
     300    }
     301
     302    millisecond = atoi(strtok(tempString, "X"));
     303    if(millisecond<0 || millisecond>1000) {
     304        psError(__func__,"Second must have a value from 0 to 999. Value: %d", millisecond);
     305    }
     306
     307    tmTime.tm_year = year - 1900;
     308    tmTime.tm_mon = month - 1;
     309    tmTime.tm_mday = day;
     310    tmTime.tm_hour = hour;
     311    tmTime.tm_min = minute;
     312    tmTime.tm_sec = second;
     313
     314    // Convert tm time to psTime
     315    outTime = psTMToTime(&tmTime);
     316    outTime.tv_usec = millisecond*1000;
     317
     318    return outTime;
     319}
     320
     321psTime psUTCToTime(psTime time)
     322{
     323    psTime outTime;
     324
     325    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
     326
     327    // Convert UTC time to psTime/TAI
     328    outTime.tv_sec = time.tv_sec + leapseconds[NUM_LEAPSECOND_UPDATES][1];
     329    ;
     330    outTime.tv_usec = time.tv_usec;
     331    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     332
     333    return time;
     334}
     335
     336psTime psMJDToTime(double time)
     337{
     338    psTime outTime;
     339    double days = 0.0;
     340    double seconds = 0.0;
     341
     342    CHECK_NEGATIVE_TIME(time,outTime);
     343
     344    // Modified Julian date conversion courtesy of Eugene Magnier
     345    days = time - 40587.0;
     346
     347    // Convert to psTime/TAI
     348    seconds = days*SEC_PER_DAY;
     349    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
     350    outTime.tv_sec = seconds;
     351
     352    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     353
     354    return outTime;
     355}
     356
     357psTime psJDToTime(double time)
     358{
     359    double days = 0.0;
     360    double seconds = 0.0;
     361    psTime outTime;
     362
     363    CHECK_NEGATIVE_TIME(time,outTime);
     364
     365    // Julian date conversion courtesy of Eugene Magnier
     366    days = time - 2440587.5;
     367
     368    // Convert to psTime/TAI
     369    seconds = days*SEC_PER_DAY;
     370    outTime.tv_sec = seconds;
     371    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
     372
     373    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     374
     375    return outTime;
     376}
     377
     378psTime psTimevalToTime(struct timeval *time)
     379{
     380    psTime outTime;
     381    if(time == NULL)
     382    {
     383        psError(__func__,"Null value for timeval arg not allowed");
     384        return outTime;
     385    } else if(time->tv_sec < 0)
     386    {
     387        psError(__func__,"Negative seconds are not allowed: %ld", time->tv_sec);
     388        return outTime;
     389    } else if(time->tv_usec<0)
     390    {
     391        psError(__func__,"Negative microseconds are not allowed: %ld", time->tv_usec);
     392        return outTime;
     393    }
     394
     395    // Convert to psTime/TAI
     396    outTime.tv_sec = time->tv_sec;
     397    outTime.tv_usec = time->tv_usec;
     398
     399    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     400
     401    return outTime;
     402}
     403
     404
     405psTime psTMToTime(struct tm *time)
     406{
     407    int i;
     408    int m;
     409    int n;
     410    int y;
     411    int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     412    long epoch;
     413    psTime outTime;
     414
     415    i= 0;
     416    m = 0;
     417    n = 0;
     418    y = 0;
     419    epoch = 0;
     420
     421    if(time == NULL)
     422    {
     423        psError(__func__,"Null value for tm arg not allowed");
     424        return outTime;
     425    } else if(time->tm_year < 70)
     426    {
     427        psError(__func__,"Input times earlier than 1970 not allowed");
     428        return outTime;
     429    }
     430
     431    n = time->tm_year + 1900 - 1;
     432    epoch = (time->tm_year - 70) * SEC_PER_YEAR + ((n/4 - n/100 + n/400) -
     433            (1969/4 - 1969/100 + 1969/400)) * SEC_PER_DAY;
     434
     435    y = time->tm_year + 1900;
     436
     437    for(i = 0; i < time->tm_mon; i++)
     438    {
     439        epoch += mon [m] * SEC_PER_DAY;
     440        if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
     441            epoch += SEC_PER_DAY;
     442        }
     443
     444        if(++m > 11) {
     445            m = 0;
     446            y++;
     447        }
     448    }
     449
     450    epoch += (time->tm_mday - 1) * SEC_PER_DAY;
     451    epoch += time->tm_hour *SEC_PER_HOUR + time->tm_min * SEC_PER_MINUTE + time->tm_sec;
     452
     453    outTime.tv_usec = 0;
     454    outTime.tv_sec = epoch;
     455
     456    return outTime;
     457}
  • trunk/psLib/src/astro/psTime.h

    r1223 r1247  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-07-15 19:02:13 $
     14 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-07-21 01:29:22 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929/// @addtogroup Time
    3030/// @{
     31
     32/******************************************************************************/
     33/*  DEFINE STATEMENTS                                                         */
     34/******************************************************************************/
     35
     36/** Number of available leapsecond updates */
     37#define NUM_LEAPSECOND_UPDATES 23
     38
     39/** Maximum length of time string */
     40#define MAX_TIME_STRING_LENGTH 256
     41
     42/** Seconds per minute */
     43#define  SEC_PER_MINUTE   60
     44
     45/** Seconds per hour */
     46#define  SEC_PER_HOUR     60*SEC_PER_MINUTE
     47
     48/** Seconds per day */
     49#define  SEC_PER_DAY      24*SEC_PER_HOUR
     50
     51/** Seconds per year */
     52#define  SEC_PER_YEAR    365*SEC_PER_DAY
     53
     54/** Microseconds per day */
     55#define USEC_PER_DAY 86400000000.0
    3156
    3257/******************************************************************************/
     
    6388/** Convert psTime to ISO time in TAI units.
    6489 *
    65  * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. The result from this
    66  * function is in TAI units.
    67  *
    68  *  @return  char*: Pointer null terminated array of chars in ISO/TAI time.
     90 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. This function assumes
     91 * the input time already is in TAI time and does not add or subtract leapseconds.
     92 *
     93 *  @return  char*: Pointer null terminated array of chars in ISO time.
    6994 */
    7095char* psTimeToISO(
     
    7499/** Convert psTime to UTC time.
    75100 *
    76  * Converts psTime to UTC time in double precision floating point notation. The result from this function is
    77  * not in TAI units, but that of UTC, which does not contain leapseconds.
    78  *
    79  *  @return  double: UTC time in floating point notation.
    80  */
    81 double psTimeToUTC(
     101 * Converts psTime to UTC time in double precision floating point notation. The input to this must already be
     102 * int TAI time. The result from this function is not in TAI units, but that of UTC, which does not contain
     103 * leapseconds.
     104 *
     105 *  @return  psTime: UTC time psTime format.
     106 */
     107psTime psTimeToUTC(
    82108    psTime time    /** Input time to be converted. */
    83109);
     
    85111/** Convert psTime to modified Julian date time.
    86112 *
    87  * Converts psTime to modified Julian date (MJD) time. The result from this function is in TAI units.
    88  *
    89  *  @return  double: MJD/TAI time in floating point notation.
     113 * Converts psTime to modified Julian date (MJD) time. This function assumes the input time already is in TAI
     114 * time and does not add or subtract leapseconds.
     115 *
     116 *  @return  double: Modified Julian Days (MJD) time.
    90117 */
    91118double psTimeToMJD(
     
    95122/** Convert psTime to Julian date time.
    96123 *
    97  * Converts psTime to Julian date (JD) time. The result from this function is in TAI units.
    98  *
    99  *  @return  double: JD/TAI time in floating point notation.
     124 * Converts psTime to Julian date (JD) time. This function assumes the input time already is in TAI time and
     125 * does not add or subtract leapseconds.
     126 *
     127 *  @return  double: Julian Date (JD) time.
    100128 */
    101129double psTimeToJD(
     
    105133/** Convert psTime to timeval time.
    106134 *
    107  * Converts psTime to timeval time. The result from this function is in TAI units.
    108  *
    109  *  @return  timeval: timeval/TAI time.
     135 * Converts psTime to timeval time. This function assumes the input time already is in TAI time and does not
     136 * add or subtract leapseconds.
     137 *
     138 *  @return  timeval: timeval struct time.
    110139 */
    111140struct timeval psTimeToTimeval(
     
    115144/** Convert psTime to tm time.
    116145 *
    117  * Converts psTime to tm time. The result from this function is in TAI units.
    118  *
    119  *  @return  tm: tm/TAI time.
     146 * Converts psTime to tm time. This function assumes the input time already is in TAI time and does not add or
     147 * subtract leapseconds.
     148 *
     149 *  @return  tm: tm struct time.
    120150 */
    121151struct tm* psTimeToTM(
     
    125155/** Convert ISO to psTime.
    126156 *
    127  * Converts ISO time to psTime. The result from this function is in TAI units.
     157 * Converts ISO time to psTime. This function assumes the input time already is in TAI time and does not add
     158 * or subtract leapseconds.
     159 *
     160 *  @return  psTime: time
     161 */
     162psTime psISOToTime(
     163    char *time  /** Input time to be converted. */
     164);
     165
     166/** Convert UTC to psTime.
     167 *
     168 * Converts UTC time to psTime. This function assumes the input time already is in TAI time and add or
     169 * subtracts the necessary leapseconds.
    128170 *
    129171 *  @return  psTime: time in TAI units.
    130172 */
    131 psTime psISOToTime(char *time);
    132 
    133 /** Convert UTC to psTime.
    134  *
    135  * Converts UTC time to psTime. The result from this function is in TAI units.
    136  *
    137  *  @return  psTime: time in TAI units.
    138  */
    139 psTime psUTCToTime(double time);
     173psTime psUTCToTime(
     174    psTime time /** Input time to be converted. */
     175);
    140176
    141177/** Convert MJD to psTime.
    142178 *
    143  * Converts MJD time to psTime. The result from this function is in TAI units.
    144  *
    145  *  @return  psTime: time in TAI units.
    146  */
    147 psTime psMJDToTime(double time);
     179 * Converts MJD time to psTime. This function assumes the input time already is in TAI time and does not add
     180 * or subtract leapseconds.
     181 *
     182 *  @return  psTime: time.
     183 */
     184psTime psMJDToTime(
     185    double time /** Input time to be converted. */
     186);
    148187
    149188/** Convert JD to psTime.
    150189 *
    151  * Converts JD time to psTime. The result from this function is in TAI units.
    152  *
    153  *  @return  psTime: time in TAI units.
    154  */
    155 psTime psJDToTime(double time);
     190 * Converts JD time to psTime. This function assumes the input time already is in TAI time and does not add
     191 * or subtract leapseconds.
     192 *
     193 *  @return  psTime: time.
     194 */
     195psTime psJDToTime(
     196    double time /** Input time to be converted. */
     197);
    156198
    157199/** Convert timeval to psTime.
    158200 *
    159  * Converts timeval time to psTime. The result from this function is in TAI units.
    160  *
    161  *  @return  psTime: time in TAI units.
    162  */
    163 psTime psTimevalToTime(struct timeval *time);
     201 * Converts timeval time to psTime. This function assumes the input time already is in TAI time and does not
     202 * add or subtract leapseconds.
     203 *
     204 *  @return  psTime: time.
     205 */
     206psTime psTimevalToTime(
     207    struct timeval *time    /** Input time to be converted. */
     208);
    164209
    165210/** Convert tm time to psTime.
    166211 *
    167  * Converts tm time to psTime. The result from this function is in TAI units.
    168  *
    169  *  @return  psTime: time in TAI units.
    170  */
    171 psTime psTMToTime(struct tm *time);
     212 * Converts tm time to psTime. This function assumes the input time already is in TAI time and does not add
     213 * or subtract leapseconds.
     214 *
     215 *  @return  psTime: time.
     216 */
     217psTime psTMToTime(
     218    struct tm *time /** Input time to be converted. */
     219);
    172220/// @}
    173221
  • trunk/psLib/src/astronomy/psTime.c

    r1223 r1247  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-07-15 19:02:13 $
     14 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-07-21 01:29:33 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424
    2525#include <stdio.h>
     26#include <stdlib.h>
     27#include <string.h>
    2628
    2729#include "psTime.h"
    2830#include "psError.h"
     31#define PS_ALLOW_MALLOC
     32#include "psMemory.h"
    2933
    3034/******************************************************************************/
     
    3236/******************************************************************************/
    3337
    34 // Number of available leapsecond updates
    35 #define NUM_LEAPSECOND_UPDATES 23
     38/** Preprocessor macro to generate error for negative time in struct */
     39#define CHECK_NEGATIVE_TIME_STRUCT(NAME,RETURN)                                                              \
     40if(NAME.tv_sec < 0) {                                                                                        \
     41    psError(__func__,"Negative seconds are not allowed: %ld", NAME.tv_sec);                                  \
     42    return RETURN;                                                                                           \
     43} else if(NAME.tv_usec<0) {                                                                                  \
     44    psError(__func__,"Negative microseconds are not allowed: %ld", NAME.tv_usec);                            \
     45    return RETURN;                                                                                           \
     46}
     47
     48/** Preprocessor macro to generate error for negative time */
     49#define CHECK_NEGATIVE_TIME(NAME,RETURN)                                                                     \
     50if(NAME < 0.0) {                                                                                             \
     51    psError(__func__,"Negative time is not allowed: %f", NAME);                                              \
     52    return RETURN;                                                                                           \
     53}                                                                                                            \
    3654
    3755/******************************************************************************/
     
    5573the psTimeGetTime() function to calculate TAI time from  UTC time.
    5674 
    57  1972 JAN  1 =JD 2441317.5  TAI-UTC= 10.0
    58  1972 JUL  1 =JD 2441499.5  TAI-UTC= 11.0
    59  1973 JAN  1 =JD 2441683.5  TAI-UTC= 12.0
    60  1974 JAN  1 =JD 2442048.5  TAI-UTC= 13.0
    61  1975 JAN  1 =JD 2442413.5  TAI-UTC= 14.0
    62  1976 JAN  1 =JD 2442778.5  TAI-UTC= 15.0
    63  1977 JAN  1 =JD 2443144.5  TAI-UTC= 16.0
    64  1978 JAN  1 =JD 2443509.5  TAI-UTC= 17.0
    65  1979 JAN  1 =JD 2443874.5  TAI-UTC= 18.0
    66  1980 JAN  1 =JD 2444239.5  TAI-UTC= 19.0
    67  1981 JUL  1 =JD 2444786.5  TAI-UTC= 20.0
    68  1982 JUL  1 =JD 2445151.5  TAI-UTC= 21.0
    69  1983 JUL  1 =JD 2445516.5  TAI-UTC= 22.0
    70  1985 JUL  1 =JD 2446247.5  TAI-UTC= 23.0
    71  1988 JAN  1 =JD 2447161.5  TAI-UTC= 24.0
    72  1990 JAN  1 =JD 2447892.5  TAI-UTC= 25.0
    73  1991 JAN  1 =JD 2448257.5  TAI-UTC= 26.0
    74  1992 JUL  1 =JD 2448804.5  TAI-UTC= 27.0
    75  1993 JUL  1 =JD 2449169.5  TAI-UTC= 28.0
    76  1994 JUL  1 =JD 2449534.5  TAI-UTC= 29.0
    77  1996 JAN  1 =JD 2450083.5  TAI-UTC= 30.0
    78  1997 JUL  1 =JD 2450630.5  TAI-UTC= 31.0
    79  1999 JAN  1 =JD 2451179.5  TAI-UTC= 32.0
     75 1972 JAN 1 = JD 2441317.5  TAI-UTC = 10.0
     76 1972 JUL 1 = JD 2441499.5  TAI-UTC = 11.0
     77 1973 JAN 1 = JD 2441683.5  TAI-UTC = 12.0
     78 1974 JAN 1 = JD 2442048.5  TAI-UTC = 13.0
     79 1975 JAN 1 = JD 2442413.5  TAI-UTC = 14.0
     80 1976 JAN 1 = JD 2442778.5  TAI-UTC = 15.0
     81 1977 JAN 1 = JD 2443144.5  TAI-UTC = 16.0
     82 1978 JAN 1 = JD 2443509.5  TAI-UTC = 17.0
     83 1979 JAN 1 = JD 2443874.5  TAI-UTC = 18.0
     84 1980 JAN 1 = JD 2444239.5  TAI-UTC = 19.0
     85 1981 JUL 1 = JD 2444786.5  TAI-UTC = 20.0
     86 1982 JUL 1 = JD 2445151.5  TAI-UTC = 21.0
     87 1983 JUL 1 = JD 2445516.5  TAI-UTC = 22.0
     88 1985 JUL 1 = JD 2446247.5  TAI-UTC = 23.0
     89 1988 JAN 1 = JD 2447161.5  TAI-UTC = 24.0
     90 1990 JAN 1 = JD 2447892.5  TAI-UTC = 25.0
     91 1991 JAN 1 = JD 2448257.5  TAI-UTC = 26.0
     92 1992 JUL 1 = JD 2448804.5  TAI-UTC = 27.0
     93 1993 JUL 1 = JD 2449169.5  TAI-UTC = 28.0
     94 1994 JUL 1 = JD 2449534.5  TAI-UTC = 29.0
     95 1996 JAN 1 = JD 2450083.5  TAI-UTC = 30.0
     96 1997 JUL 1 = JD 2450630.5  TAI-UTC = 31.0
     97 1999 JAN 1 = JD 2451179.5  TAI-UTC = 32.0
    8098*/
    8199
    82 // Julian date of leapsecond update and current total number of leapseconds for that date
     100// Table for Julian date of leapsecond update and current total number of leapseconds at that date
    83101static double leapseconds[NUM_LEAPSECOND_UPDATES][2] =
    84102    {
     
    135153    time.tv_usec = now.tv_usec;
    136154
    137     // Add last known leapseconds to UTC time to get TAI time
     155    // Add most current leapseconds value to UTC time to get TAI time
    138156    time.tv_sec += leapseconds[NUM_LEAPSECOND_UPDATES][1];
    139157
     
    143161char* psTimeToISO(psTime time)
    144162{
    145     struct tm *tm;
    146     tm = localtime (&time.tv_sec);
    147     printf("%d\n", tm->tm_sec);
    148     return NULL;
    149 }
     163    int ms = 0;
     164    char *timeString = NULL;
     165    char *tempString = NULL;
     166    struct tm *tmTime = NULL;
     167
     168    CHECK_NEGATIVE_TIME_STRUCT(time,NULL);
     169
     170    tempString = psAlloc(MAX_TIME_STRING_LENGTH);
     171    timeString = psAlloc(MAX_TIME_STRING_LENGTH);
     172
     173    // Converts psTime to YYYY/MM/DD,HH:MM:SS.SSS in string form
     174    ms = time.tv_usec/1000;
     175    tmTime = gmtime(&time.tv_sec);
     176    if(!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y/%m/%d,%H:%M:%S", tmTime)) {
     177        psError(__func__, " : Line %d - Failed strftime conversion", __LINE__);
     178    }
     179
     180    if(snprintf(timeString,MAX_TIME_STRING_LENGTH,"%s.%3.3d", tempString, ms) < 0) {
     181        psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__);
     182    }
     183    psFree(tempString);
     184    free(tmTime);
     185
     186    return timeString;
     187}
     188
     189psTime psTimeToUTC(psTime time)
     190{
     191    int i = 0;
     192    double jd = 0.0;
     193    double ls = 0.0;
     194    double *jdTable = NULL;
     195    psTime outTime;
     196
     197    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
     198
     199    // Find leapseconds to subtract from psTime to get UTC time
     200    jd = psTimeToJD(time);
     201    jdTable = leapseconds[0];
     202    for(i=0; i<NUM_LEAPSECOND_UPDATES; i++, jdTable+=2) {
     203        if(jd > *jdTable) {
     204            ls = *(jdTable + 1);
     205        }
     206    }
     207
     208    outTime.tv_sec = time.tv_sec - ls;
     209    outTime.tv_usec = time.tv_usec;
     210
     211    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     212
     213    return outTime;
     214}
     215
     216double psTimeToMJD(psTime time)
     217{
     218    double mjd = 0.0;
     219
     220    CHECK_NEGATIVE_TIME_STRUCT(time,mjd);
     221
     222    // Modified Julian date conversion courtesy of Eugene Magnier
     223    mjd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 40587.0;
     224
     225    return mjd;
     226}
     227
     228double psTimeToJD(psTime time)
     229{
     230    double jd = 0.0;
     231
     232    CHECK_NEGATIVE_TIME_STRUCT(time,jd);
     233
     234    // Julian date conversion courtesy of Eugene Magnier
     235    jd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 2440587.5;
     236
     237    return jd;
     238}
     239
     240struct timeval psTimeToTimeval(psTime time)
     241{
     242    struct timeval timevalTime;
     243
     244    CHECK_NEGATIVE_TIME_STRUCT(time,timevalTime);
     245    timevalTime.tv_sec = time.tv_sec;
     246    timevalTime.tv_usec = time.tv_usec;
     247
     248    return timevalTime;
     249}
     250
     251struct tm* psTimeToTM(psTime time)
     252{
     253    struct tm *tmTime = NULL;
     254
     255    CHECK_NEGATIVE_TIME_STRUCT(time,tmTime);
     256    tmTime = gmtime(&time.tv_sec);
     257
     258    return tmTime;
     259}
     260
     261psTime psISOToTime(char *time)
     262{
     263    char tempString[MAX_TIME_STRING_LENGTH];
     264    int month;
     265    int day;
     266    int year;
     267    int hour;
     268    int minute;
     269    int second;
     270    int millisecond;
     271    struct tm tmTime;
     272    psTime outTime;
     273
     274    strncpy(tempString, time, MAX_TIME_STRING_LENGTH);
     275
     276    // Convert YYYY/MM/DD,HH:MM:SS.SSS in string form to tm time
     277    year = atoi(strtok(tempString, "/"));
     278    if(year < 0) {
     279        psError(__func__,"Years less than 1900 not allowed. Value: %d", year);
     280    }
     281
     282    month = atoi(strtok(tempString, "/"));
     283    if(month<1 || month>12) {
     284        psError(__func__,"Month must have a value from 0 to 11. Value: %d", month);
     285    }
     286
     287    day = atoi(strtok(tempString, ","));
     288    if(day<1 || day>31) {
     289        psError(__func__,"Day must have a value from 1 to 31. Value: %d", day);
     290    }
     291
     292    hour = atoi(strtok(tempString, ":"));
     293    if(hour<0 || hour>23) {
     294        psError(__func__,"Hour must have a value from 0 to 23. Value: %d", hour);
     295    }
     296
     297    second = atoi(strtok(tempString, "."));
     298    if(second<0 || second>60) {
     299        psError(__func__,"Second must have a value from 0 to 59. Value: %d", second);
     300    }
     301
     302    millisecond = atoi(strtok(tempString, "X"));
     303    if(millisecond<0 || millisecond>1000) {
     304        psError(__func__,"Second must have a value from 0 to 999. Value: %d", millisecond);
     305    }
     306
     307    tmTime.tm_year = year - 1900;
     308    tmTime.tm_mon = month - 1;
     309    tmTime.tm_mday = day;
     310    tmTime.tm_hour = hour;
     311    tmTime.tm_min = minute;
     312    tmTime.tm_sec = second;
     313
     314    // Convert tm time to psTime
     315    outTime = psTMToTime(&tmTime);
     316    outTime.tv_usec = millisecond*1000;
     317
     318    return outTime;
     319}
     320
     321psTime psUTCToTime(psTime time)
     322{
     323    psTime outTime;
     324
     325    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
     326
     327    // Convert UTC time to psTime/TAI
     328    outTime.tv_sec = time.tv_sec + leapseconds[NUM_LEAPSECOND_UPDATES][1];
     329    ;
     330    outTime.tv_usec = time.tv_usec;
     331    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     332
     333    return time;
     334}
     335
     336psTime psMJDToTime(double time)
     337{
     338    psTime outTime;
     339    double days = 0.0;
     340    double seconds = 0.0;
     341
     342    CHECK_NEGATIVE_TIME(time,outTime);
     343
     344    // Modified Julian date conversion courtesy of Eugene Magnier
     345    days = time - 40587.0;
     346
     347    // Convert to psTime/TAI
     348    seconds = days*SEC_PER_DAY;
     349    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
     350    outTime.tv_sec = seconds;
     351
     352    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     353
     354    return outTime;
     355}
     356
     357psTime psJDToTime(double time)
     358{
     359    double days = 0.0;
     360    double seconds = 0.0;
     361    psTime outTime;
     362
     363    CHECK_NEGATIVE_TIME(time,outTime);
     364
     365    // Julian date conversion courtesy of Eugene Magnier
     366    days = time - 2440587.5;
     367
     368    // Convert to psTime/TAI
     369    seconds = days*SEC_PER_DAY;
     370    outTime.tv_sec = seconds;
     371    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
     372
     373    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     374
     375    return outTime;
     376}
     377
     378psTime psTimevalToTime(struct timeval *time)
     379{
     380    psTime outTime;
     381    if(time == NULL)
     382    {
     383        psError(__func__,"Null value for timeval arg not allowed");
     384        return outTime;
     385    } else if(time->tv_sec < 0)
     386    {
     387        psError(__func__,"Negative seconds are not allowed: %ld", time->tv_sec);
     388        return outTime;
     389    } else if(time->tv_usec<0)
     390    {
     391        psError(__func__,"Negative microseconds are not allowed: %ld", time->tv_usec);
     392        return outTime;
     393    }
     394
     395    // Convert to psTime/TAI
     396    outTime.tv_sec = time->tv_sec;
     397    outTime.tv_usec = time->tv_usec;
     398
     399    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
     400
     401    return outTime;
     402}
     403
     404
     405psTime psTMToTime(struct tm *time)
     406{
     407    int i;
     408    int m;
     409    int n;
     410    int y;
     411    int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
     412    long epoch;
     413    psTime outTime;
     414
     415    i= 0;
     416    m = 0;
     417    n = 0;
     418    y = 0;
     419    epoch = 0;
     420
     421    if(time == NULL)
     422    {
     423        psError(__func__,"Null value for tm arg not allowed");
     424        return outTime;
     425    } else if(time->tm_year < 70)
     426    {
     427        psError(__func__,"Input times earlier than 1970 not allowed");
     428        return outTime;
     429    }
     430
     431    n = time->tm_year + 1900 - 1;
     432    epoch = (time->tm_year - 70) * SEC_PER_YEAR + ((n/4 - n/100 + n/400) -
     433            (1969/4 - 1969/100 + 1969/400)) * SEC_PER_DAY;
     434
     435    y = time->tm_year + 1900;
     436
     437    for(i = 0; i < time->tm_mon; i++)
     438    {
     439        epoch += mon [m] * SEC_PER_DAY;
     440        if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
     441            epoch += SEC_PER_DAY;
     442        }
     443
     444        if(++m > 11) {
     445            m = 0;
     446            y++;
     447        }
     448    }
     449
     450    epoch += (time->tm_mday - 1) * SEC_PER_DAY;
     451    epoch += time->tm_hour *SEC_PER_HOUR + time->tm_min * SEC_PER_MINUTE + time->tm_sec;
     452
     453    outTime.tv_usec = 0;
     454    outTime.tv_sec = epoch;
     455
     456    return outTime;
     457}
  • trunk/psLib/src/astronomy/psTime.h

    r1223 r1247  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2004-07-15 19:02:13 $
     14 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2004-07-21 01:29:22 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2929/// @addtogroup Time
    3030/// @{
     31
     32/******************************************************************************/
     33/*  DEFINE STATEMENTS                                                         */
     34/******************************************************************************/
     35
     36/** Number of available leapsecond updates */
     37#define NUM_LEAPSECOND_UPDATES 23
     38
     39/** Maximum length of time string */
     40#define MAX_TIME_STRING_LENGTH 256
     41
     42/** Seconds per minute */
     43#define  SEC_PER_MINUTE   60
     44
     45/** Seconds per hour */
     46#define  SEC_PER_HOUR     60*SEC_PER_MINUTE
     47
     48/** Seconds per day */
     49#define  SEC_PER_DAY      24*SEC_PER_HOUR
     50
     51/** Seconds per year */
     52#define  SEC_PER_YEAR    365*SEC_PER_DAY
     53
     54/** Microseconds per day */
     55#define USEC_PER_DAY 86400000000.0
    3156
    3257/******************************************************************************/
     
    6388/** Convert psTime to ISO time in TAI units.
    6489 *
    65  * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. The result from this
    66  * function is in TAI units.
    67  *
    68  *  @return  char*: Pointer null terminated array of chars in ISO/TAI time.
     90 * Converts psTime to a null terminated string in the form of: YYYY/MM/DD,HH:MM:SS.SSS. This function assumes
     91 * the input time already is in TAI time and does not add or subtract leapseconds.
     92 *
     93 *  @return  char*: Pointer null terminated array of chars in ISO time.
    6994 */
    7095char* psTimeToISO(
     
    7499/** Convert psTime to UTC time.
    75100 *
    76  * Converts psTime to UTC time in double precision floating point notation. The result from this function is
    77  * not in TAI units, but that of UTC, which does not contain leapseconds.
    78  *
    79  *  @return  double: UTC time in floating point notation.
    80  */
    81 double psTimeToUTC(
     101 * Converts psTime to UTC time in double precision floating point notation. The input to this must already be
     102 * int TAI time. The result from this function is not in TAI units, but that of UTC, which does not contain
     103 * leapseconds.
     104 *
     105 *  @return  psTime: UTC time psTime format.
     106 */
     107psTime psTimeToUTC(
    82108    psTime time    /** Input time to be converted. */
    83109);
     
    85111/** Convert psTime to modified Julian date time.
    86112 *
    87  * Converts psTime to modified Julian date (MJD) time. The result from this function is in TAI units.
    88  *
    89  *  @return  double: MJD/TAI time in floating point notation.
     113 * Converts psTime to modified Julian date (MJD) time. This function assumes the input time already is in TAI
     114 * time and does not add or subtract leapseconds.
     115 *
     116 *  @return  double: Modified Julian Days (MJD) time.
    90117 */
    91118double psTimeToMJD(
     
    95122/** Convert psTime to Julian date time.
    96123 *
    97  * Converts psTime to Julian date (JD) time. The result from this function is in TAI units.
    98  *
    99  *  @return  double: JD/TAI time in floating point notation.
     124 * Converts psTime to Julian date (JD) time. This function assumes the input time already is in TAI time and
     125 * does not add or subtract leapseconds.
     126 *
     127 *  @return  double: Julian Date (JD) time.
    100128 */
    101129double psTimeToJD(
     
    105133/** Convert psTime to timeval time.
    106134 *
    107  * Converts psTime to timeval time. The result from this function is in TAI units.
    108  *
    109  *  @return  timeval: timeval/TAI time.
     135 * Converts psTime to timeval time. This function assumes the input time already is in TAI time and does not
     136 * add or subtract leapseconds.
     137 *
     138 *  @return  timeval: timeval struct time.
    110139 */
    111140struct timeval psTimeToTimeval(
     
    115144/** Convert psTime to tm time.
    116145 *
    117  * Converts psTime to tm time. The result from this function is in TAI units.
    118  *
    119  *  @return  tm: tm/TAI time.
     146 * Converts psTime to tm time. This function assumes the input time already is in TAI time and does not add or
     147 * subtract leapseconds.
     148 *
     149 *  @return  tm: tm struct time.
    120150 */
    121151struct tm* psTimeToTM(
     
    125155/** Convert ISO to psTime.
    126156 *
    127  * Converts ISO time to psTime. The result from this function is in TAI units.
     157 * Converts ISO time to psTime. This function assumes the input time already is in TAI time and does not add
     158 * or subtract leapseconds.
     159 *
     160 *  @return  psTime: time
     161 */
     162psTime psISOToTime(
     163    char *time  /** Input time to be converted. */
     164);
     165
     166/** Convert UTC to psTime.
     167 *
     168 * Converts UTC time to psTime. This function assumes the input time already is in TAI time and add or
     169 * subtracts the necessary leapseconds.
    128170 *
    129171 *  @return  psTime: time in TAI units.
    130172 */
    131 psTime psISOToTime(char *time);
    132 
    133 /** Convert UTC to psTime.
    134  *
    135  * Converts UTC time to psTime. The result from this function is in TAI units.
    136  *
    137  *  @return  psTime: time in TAI units.
    138  */
    139 psTime psUTCToTime(double time);
     173psTime psUTCToTime(
     174    psTime time /** Input time to be converted. */
     175);
    140176
    141177/** Convert MJD to psTime.
    142178 *
    143  * Converts MJD time to psTime. The result from this function is in TAI units.
    144  *
    145  *  @return  psTime: time in TAI units.
    146  */
    147 psTime psMJDToTime(double time);
     179 * Converts MJD time to psTime. This function assumes the input time already is in TAI time and does not add
     180 * or subtract leapseconds.
     181 *
     182 *  @return  psTime: time.
     183 */
     184psTime psMJDToTime(
     185    double time /** Input time to be converted. */
     186);
    148187
    149188/** Convert JD to psTime.
    150189 *
    151  * Converts JD time to psTime. The result from this function is in TAI units.
    152  *
    153  *  @return  psTime: time in TAI units.
    154  */
    155 psTime psJDToTime(double time);
     190 * Converts JD time to psTime. This function assumes the input time already is in TAI time and does not add
     191 * or subtract leapseconds.
     192 *
     193 *  @return  psTime: time.
     194 */
     195psTime psJDToTime(
     196    double time /** Input time to be converted. */
     197);
    156198
    157199/** Convert timeval to psTime.
    158200 *
    159  * Converts timeval time to psTime. The result from this function is in TAI units.
    160  *
    161  *  @return  psTime: time in TAI units.
    162  */
    163 psTime psTimevalToTime(struct timeval *time);
     201 * Converts timeval time to psTime. This function assumes the input time already is in TAI time and does not
     202 * add or subtract leapseconds.
     203 *
     204 *  @return  psTime: time.
     205 */
     206psTime psTimevalToTime(
     207    struct timeval *time    /** Input time to be converted. */
     208);
    164209
    165210/** Convert tm time to psTime.
    166211 *
    167  * Converts tm time to psTime. The result from this function is in TAI units.
    168  *
    169  *  @return  psTime: time in TAI units.
    170  */
    171 psTime psTMToTime(struct tm *time);
     212 * Converts tm time to psTime. This function assumes the input time already is in TAI time and does not add
     213 * or subtract leapseconds.
     214 *
     215 *  @return  psTime: time.
     216 */
     217psTime psTMToTime(
     218    struct tm *time /** Input time to be converted. */
     219);
    172220/// @}
    173221
Note: See TracChangeset for help on using the changeset viewer.