These routines have the following functions:
The time() function is called by:
|
INTEGER*4 time or INTEGER*8 n = time() Standard Version |
|||
|
Return value |
INTEGER*4 |
Output |
Time, in seconds, since 0:0:0, GMT, 1/1/70 |
|
INTEGER*8 |
Output |
In 64-bit environments, time returns an INTEGER*8 value |
|
The function time() returns an integer with the time since 00:00:00 GMT, January 1, 1970, measured in seconds. This is the value of the operating system clock.
Example: time(), version standard with the operating system:
demo% cat ttime.f
INTEGER*4 n, time
n = time()
write(*,*) ’Seconds since 0 1/1/70 GMT = ’, n
end
demo% f95 ttime.f
demo% a.out
Seconds since 0 1/1/70 GMT = 913240205
demo%
|
The function ctime converts a system time, stime, and returns it as a 24-character ASCII string.
The function is called by:
|
CHARACTER ctime*24 string = ctime( stime ) |
|||
|
stime |
INTEGER*4 |
Input |
System time from time() (standard version) |
|
Return value |
character*24 |
Output |
System time as character string. Declare ctime and string as character*24. |
The format of the ctime returned value is shown in the following example. It is described in the man page ctime(3C).
Example: ctime():
demo% cat tctime.f
character*24 ctime, string
INTEGER*4 n, time
n = time()
string = ctime( n )
write(*,*) ’ctime: ’, string
end
demo% f95 tctime.f
demo% a.out
ctime: Wed Dec 9 13:50:05 1998
demo%
|
This routine dissects a system time into month, day, and so forth, for the local time zone.
The subroutine is called by:
|
call ltime( stime, tarray ) |
|||
|
stime |
INTEGER*4 |
Input |
System time from time() (standard version) |
|
tarray |
INTEGER*4(9) |
Output |
System time, local, as day, month, year, … |
For the meaning of the elements in tarray, see the next section.
demo% cat tltime.f
integer*4 stime, tarray(9), time
stime = time()
call ltime( stime, tarray )
write(*,*) ’ltime: ’, tarray
end
demo% f95 tltime.f
demo% a.out
ltime: 25 49 10 12 7 91 1 223 1
demo%
|
This routine dissects a system time into month, day, and so on, for GMT.
The subroutine is:
|
call gmtime( stime, tarray ) |
|||
|
stime |
INTEGER*4 |
Input |
System time from time() (standard version) |
|
tarray |
INTEGER*4(9) |
Output |
System time, GMT, as day, month, year, … |
demo% cat tgmtime.f
integer*4 stime, tarray(9), time
stime = time()
call gmtime( stime, tarray )
write(*,*) ’gmtime: ’, tarray
end
demo% f95t tgmtime.f
demo% a.out
gmtime: 12 44 19 18 5 94 6 168 0
demo%
|
Here are the tarray() values for ltime and gmtime: index, units, and range:
|
1 2 3 4 5 |
Seconds (0 - 61) Minutes (0 - 59) Hours (0 - 23) Day of month (1 - 31) Months since January (0 - 11) |
6 7 8 9 |
Year - 1900 Day of week (Sunday = 0) Day of year (0 - 365) Daylight Saving Time, 1 if DST in effect |
These values are defined by the C library routine ctime(3C), which explains why the system may return a count of seconds greater than 59. See also: idate(3F), and fdate(3F).
These are versions of the corresponding routines ctime, gmtime, and ltime, to provide portability on 64-bit environments. They are identical to these routines except that the input variable stime must be INTEGER*8.
When used in a 32-bit environment with an INTEGER*8 stime, if the value of stime is beyond the INTEGER*4 range ctime64 returns all asterisks, while gmtime and ltime fill the tarray array with -1.