INTEGER FUNCTION SECSDIFF( ADATE, ATIME, ZDATE, ZTIME ) INTEGER, INTENT(IN ) :: ADATE, ATIME ! starting date&time INTEGER, INTENT(IN ) :: ZDATE, ZTIME ! ending date&time
int secsdiffc( int adate , int atime , int zdate , int ztime )
SECSDIFF()
returns the number of seconds in the time interval starting atADATE:ATIME
and ending atZDATE:ZTIME
(which will be positive if and only ifZDATE:ZTIME
is afterADATE:ATIME
(and negative if these are reversed). This routine is coded so as to avoidINTEGER
-overflow to the extent possible. Note, however, thatINTEGER
seconds overflows for date-differences larger than about 68 years.For Fortran-90 declarations and interface checking:
USE M3UTILIOSee also SEC2TIME() and TIME2SEC()
#include "iodecl3.h"
for C.
ADATE, ATIME, ZDATE, ZTIME
expressed according to Models-3 date and time conventions.
ADATE:ATIME—ZDATE:ZTIME
represents a time interval of at most 68 years.
... USE M3UTILIO ... INTEGER SECS ... SECS = SECSDIFF( 1988001, 1, 1989365, 235959 ) !! Now SECS is the number of seconds from one second after !! midnight on New Year's Day, 1988 until one second before !! midnight on New Year's EVE, 1989. Will be 63,071,998. ... SECS = SECSDIFF( 1988001, 0, 1988001, 1000000 ) !! Now SECS is 36000000, the number of seconds in 100 hours. !! The time component in the arguments need not be normalized... ...
... #include "iodecl3.h" ... int secs ; ... secs = secsdiffc( 1989365, 235959, 1988001, 1 ) ; /* Now secs == -63,071,998 is negative, since this interval goes _backwards_ in time */ ...
Up: Date-Time Manipulation Routines
To: Models-3/EDSS I/O API: The Help Pages