00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if 0
00023 <lalVerbatim file="GPSTimeNowCV">
00024 Author: Duncan Brown
00025 $Id: GPSTimeNow.c,v 1.5 2008/04/29 21:30:15 kipp Exp $
00026 </lalVerbatim>
00027
00028 <lalLaTeX>
00029 \subsection{Module \texttt{GPSTimeNow.c}}
00030 \label{ss:GPSTimeNow.c}
00031
00032 Routine to convert the current unix system clock time into a
00033 \texttt{LIGOTimeGPS} structure.
00034
00035 \subsection*{Prototypes}
00036 \vspace{0.1in}
00037 \input{GPSTimeNowCP}
00038 \idx{LALGPSTimeNow()}
00039
00040 \subsubsection*{Description}
00041
00042 This module contains a single funtion that converts the current unix system
00043 time as returned by the \texttt{time()} function to GPS seconds. The leap
00044 second accuracy is determined by the \texttt{accuracy} argument.
00045
00046 \subsubsection*{Algorithm}
00047
00048 \subsubsection*{Uses}
00049
00050 \subsubsection*{Notes}
00051
00052 If the system clock time is incorect, the returned GPS time will obviously be
00053 wrong by the same amount.
00054
00055 \vfill{\footnotesize\input{GPSTimeNowCV}}
00056 </lalLaTeX>
00057 #endif
00058
00059 #include <time.h>
00060 #include <lal/Date.h>
00061 #include <lal/XLALError.h>
00062
00063 NRCSID( GPSTIMENOWC, "$Id: GPSTimeNow.c,v 1.5 2008/04/29 21:30:15 kipp Exp $" );
00064
00065
00066 LIGOTimeGPS *
00067 XLALGPSTimeNow (
00068 LIGOTimeGPS *gpstime
00069 )
00070
00071 {
00072 static const char func[] = "XLALGPSTimeNow";
00073 time_t ticks = time(NULL);
00074
00075 gpstime->gpsSeconds = XLALUTCToGPS(gmtime(&ticks));
00076 gpstime->gpsNanoSeconds = 0;
00077
00078
00079
00080 if(gpstime->gpsSeconds < 0)
00081 XLAL_ERROR_NULL(func, XLAL_EFUNC);
00082
00083 return gpstime;
00084 }
00085
00086
00087
00088 void
00089 LALGPSTimeNow (
00090 LALStatus *status,
00091 LIGOTimeGPS *gpstime,
00092 const LALLeapSecAccuracy *accuracy
00093 )
00094
00095 {
00096 INITSTATUS( status, "LALGPSTimeNow", GPSTIMENOWC );
00097 ATTATCHSTATUSPTR( status );
00098 ASSERT( gpstime, status, DATEH_ENULLOUTPUT, DATEH_MSGENULLOUTPUT );
00099 ASSERT( accuracy, status, DATEH_ENULLINPUT, DATEH_MSGENULLINPUT );
00100
00101 ASSERT( XLALGPSTimeNow(gpstime), status, DATEH_EDATETOOEARLY, DATEH_MSGEDATETOOEARLY );
00102
00103 XLALPrintDeprecationWarning("LALGPSTimeNow", "XLALGPSTimeNow");
00104
00105 DETATCHSTATUSPTR( status );
00106 RETURN( status );
00107 }