IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 13, 2004, 2:30:36 PM (22 years ago)
Author:
jhoblitt
Message:

ruff draft of the date and time handling API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/psLibSDRS.tex

    r1527 r1534  
    1 %%% $Id: psLibSDRS.tex,v 1.67 2004-08-13 20:50:59 price Exp $
     1%%% $Id: psLibSDRS.tex,v 1.68 2004-08-14 00:30:36 jhoblitt Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    30173017\subsection{Dates and times}
    30183018
    3019 We require a collection of functions to manipulate time data.  These
    3020 operations primarily consist of conversions between specific time
    3021 formats.  PSLib currently uses the UNIX \code{timeval} structure
    3022 representation of time as the native time format.
    3023 \begin{verbatim}
     3019We require a collection of functions to manipulate time data.  These operations
     3020primarily consist of conversions between specific time formats.  Internally,
     3021PSLib handles times as struct similar to the POSIX \code{struct timeval} which
     3022has been extended to track the time system being represented.
     3023
     3024\begin{verbatim}
     3025typedef enum {
     3026    PS_TIME_TAI,                    /* seconds since 1970-01-01T00:00:00Z (Gregorian) */
     3027    PS_TIME_UTC,                    /* seconds since 1970-01-01T00:00:00Z (Gregorian) */
     3028    PS_TIME_UT1,                    /* seconds since 1970-01-01T00:00:00Z (Gregorian) */
     3029    PS_TIME_LST,                    /* seconds since 1970-01-01T00:00:00Z (Gregorian) */
     3030} psTimeType;
     3031
    30243032typedef struct {
    3025   time_t         tv_sec;   /* seconds */
    3026   suseconds_t    tv_usec;  /* microseconds */
     3033    psU64            sec;           /* seconds */
     3034    psU32            nsec;          /* nanoseconds */
     3035    psTimeType       type;          /* type of time */
    30273036} psTime;
    30283037\end{verbatim}
    30293038
     3039A number of functions are provided to get the current time in a particular time
     3040system.
     3041
     3042\begin{verbatim}
     3043psTime *psGetTAI(void);
     3044psTime *psGetUTC(void);
     3045psTime *psGetUT1(void);
     3046psTime *psGetLST(psF64 longitude);
     3047psF64 *psGetJD(void);
     3048psF64 *psGetMJD(void);
     3049\end{verbatim}
     3050
     3051When converting to a time system the source time system is automaticaly
     3052converted to TAI and then from TAI to the destination type.
     3053
     3054\begin{verbatim}
     3055bool psTimeToTAI(psTimeType type, psTime *time);
     3056bool psTimeToUTC(psTimeType type, psTime *time);
     3057bool psTimeToUT1(psTimeType type, psTime *time);
     3058bool psTimeToLST(psTimeType type, psTime *time);
     3059psF64 psTimeToJD(psTime *time);
     3060psF64 psTimeToMJD(psTime *time);
     3061\end{verbatim}
     3062
     3063A collection of functions convert from the \code{psTime} types to various
     3064external formats.  Note that ISO8601 format is "YYYY-MM-DDThh:mm:ss,sZ"
     3065
     3066\begin{verbatim}
     3067char *psFormatISO8601(psTime *time);
     3068struct timeval *psFormatTimeval(psTime *time);
     3069\end{verbatim}
     3070
     3071A related collection of functions convert from external formats to a
     3072\code{psTime} type.
     3073
     3074\begin{verbatim}
     3075psTime *psParseISO8601(psTimeType type, char *input);
     3076psTime *psParseTimeval(psTimeType type, struct timeval *input);
     3077\end{verbatim}
     3078
     3079All \code{psTime} types must be able to be converted to to the TAI type.
     3080Conversion from one \code{psTime} type to another is achieved by first
     3081converting to TAI and then to the target type.
     3082
     3083\begin{verbatim}
     3084psTime *psTAIToUTC(psTime *time);
     3085psTime *psUTCToTAI(psTime *time);
     3086\end{verbatim}
     3087
    30303088A utility function provides the current time from the system clock, in correct TAI units:
    30313089\begin{verbatim}
    3032 psTime psTimeGetTime (void);
    3033 \end{verbatim}
    3034 
    3035 A collection of functions convert from the native \code{psTime} format
    3036 to various external formats.  Note that ISO Time is represented by
    3037 YYYY/MM/DD,HH:MM:SS.SSS. 
    3038 \begin{verbatim}
    3039 char *psTimeToISOTime (psTime time);
    3040 double psTimeToUTC (psTime time);
    3041 double psTimeToMJD (psTime time);
    3042 double psTimeToJD (psTime time);
    3043 struct timeval *psTimeToTimeval (psTime time);
    3044 struct tm *psTimeToTm (psTime time);
    3045 \end{verbatim}
    3046 
    3047 A matching set of functions convert from the external formats to the
    3048 native \code{psTime}:
    3049 \begin{verbatim}
    3050 psTime *psISOTimeToTime (char *input);
    3051 psTime *psUTCToTime (double input);
    3052 psTime *psMJDToTime (double input);
    3053 psTime *psJDToTime (double input);
    3054 psTime *psTimevalToTime (struct timeval *input);
    3055 psTime *psTMtoTime (struct tm *input);
     3090psTime *psTAIToUT1(psTime *time);
     3091psTime *psUT1ToTAI(psTime *time);
     3092\end{verbatim}
     3093
     3094\begin{verbatim}
     3095psTime *psTAIToLST(psTime *time, double longitude);
     3096psTime *psLSTToTAI(psTime *time, double longitude);
     3097\end{verbatim}
     3098
     3099A number of utility functions is needed for type conversion.
     3100
     3101\begin{verbatim}
     3102psTime *psUT1ToGMST00(psTime *time);
     3103psTime *psGMST00ToUT1(psTime *time);
     3104\end{verbatim}
     3105
     3106\begin{verbatim}
     3107psTime *psGMST00ToLST(psTime *time, double longitude);
     3108psTime *psLSTToGMST00(psTime *time, double longitude);
     3109\end{verbatim}
     3110
     3111Conversions to/from Julian Centuries.
     3112
     3113\begin{verbatim}
     3114psF64 psJDToJC(psF64 time);
     3115psF64 psJCToJD(psF64 time);
     3116\end{verbatim}
     3117
     3118\begin{verbatim}
     3119psF64 psMJDToJC(psF64 time);
     3120psF64 psJCToMJD(psF64 time);
     3121\end{verbatim}
     3122
     3123\begin{verbatim}
     3124unsigned int psGetLeapSeconds(psTime *utc);
     3125\end{verbatim}
     3126
     3127\begin{verbatim}
     3128double psGetUT1Delta(psTime *tai);
     3129\end{verbatim}
     3130
     3131Time math is only done on the \code{psTime} TAI type.
     3132
     3133\begin{verbatim}
     3134psTime *psTAIAdd(psTime *tai1, psTime *tai2);
     3135psTime *psTAISub(psTime *tai1, psTime *tai2);
     3136psTime *psTAIDelta(psTime *tai1, psTime *tai2);
    30563137\end{verbatim}
    30573138
Note: See TracChangeset for help on using the changeset viewer.