1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* Ftools info: $Header: /software/lheasoft/lheavc/ftools_42/src/ftoolslib/unx/gttime.c,v 1.1 1998/06/26 03:19:14 guerber Exp $ */
/***************************************************************************
*
* gttime: Get current system time, returning hours, minutes, and seconds
* as integers. Time will be UTC if available, else local.
*
* This is a reimplementation of /library/utilties/unx/gttime.f, reading
* the standard C time structure instead of calling xanlib's gettim, which
* uses the system-dependent fdate() call.
*
* To get the system date as integers, use the Cfitsio routine ffgsdt/ftgsdt.
*
* AUTHOR: Jeff Guerber, Raytheon STX / NASA-GSFC, June 25, 1998.
* Based largely on the cfitsio function ffgsdt().
*
* MODIFICATION HISTORY:
* $Log: gttime.c,v $
* Revision 1.1 1998/06/26 03:19:14 guerber
* Get system time, returning integers. Replaces library/utilities/unx/gttime.f.
*
*
***************************************************************************/
/***************************************************************************
* Downloaded by thierry@FreeBSD.org on Nov. 22 2012
* from ftp://legacy.gsfc.nasa.gov/software/ftools/release/FTools_4.2/ftools_42/src/ftoolslib/unx/gttime.c
* See http://heasarc.gsfc.nasa.gov/docs/software/ftools/ftools_menu.html
* FV License Agreement: http://heasarc.gsfc.nasa.gov/docs/software/ftools/fv/doc/license.html
*
***************************************************************************/
#include <stdio.h>
#include <time.h>
#include <cfortran.h>
void gttime( int *hr, int *min, int *sec )
{
time_t sysclk;
struct tm *timep;
sysclk = time( NULL );
timep = gmtime( &sysclk );
if ( timep == NULL ) { /* UTC isn't available so use local time */
timep = localtime( &sysclk );
}
*hr = timep->tm_hour;
*min = timep->tm_min;
*sec = timep->tm_sec;
return;
}
FCALLSCSUB3(gttime,GTTIME,gttime,PINT,PINT,PINT)
|