home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1995 by Oracle Corporation. All Rights Reserved.
- *
- * ystm.h - Time Management
- */
-
- #ifndef YSTM_ORACLE
- #define YSTM_ORACLE
-
- #ifndef SYSX_ORACLE
- #include <sysx.h>
- #endif
-
- EXTC_START
-
- typedef struct ystm ystm; /* structured time */
-
- /* DISABLE check_naming */
- struct ystm
- {
- ub4 usec; /* microseconds (0-999999) */
- sword sec; /* seconds (0-59) */
- sword min; /* minutes (0-59) */
- sword hour; /* hours (0-23) */
- sword mday; /* day of month (1-31) */
- sword mon; /* month of year (1-12) */
- sword year; /* year */
- boolean sign; /* TRUE if sign is positive (for delta times only) */
- };
- /* ENABLE check_naming */
-
- /*
- * ysClock - get the current time
- *
- * DESCRIPTION
- * ysClock() retrives the current time. The time is represented as a number
- * of microseconds since some epoch. The time is returned in clk as a 64-bit
- * signed integer. This value wraps approximately every 292 thousand years.
- *
- * The time returned by ysClock() is guaranteed to be monotonically increasing
- * throughout the lifetime of the process. The clock may be based on a
- * hardware tick counter or on a real-time clock. In the latter case,
- * ysClock() may lose accuracy if the underlying real-time clock is reset by
- * an administrator, but will continue to ensure monotonicity.
- *
- * WARNINGS
- * The granularity of the clock value is usually larger than microseconds.
- *
- * On hosts where no real-time clock is available, the epoch may restart
- * at zero every time the machine is rebooted. This will affect the calendar
- * time reported by ysConvClock() and ysStrClock().
- *
- * The clock is only guaranteed to be consistent within a single process,
- * although it will almost always be consistent within a single host. Across
- * hosts, you must use a distributed time facility if synchronized time
- * information is required.
- */
- void ysClock(sysb8 *clk);
-
- /*
- * ysConvClock, ysConvDelta - convert to structured form
- *
- * DESCRIPTION
- * ysConvClock() converts from a clock value to a structured form. The result
- * is written to sttm. The time returned is "local" time.
- *
- * ysConvDelta() converts from a delta clock value to a structured form.
- * A delta clock value is the computed difference between two clock values
- * obtained from ysClock(). The result is written to sttm. The mon and
- * year fields of sttm are not used. The mday field contains the number of
- * days (which may represent any number of days to about 89 years before
- * overflow occurs.)
- */
- void ysConvClock(sysb8 *clk, ystm *sttm);
- void ysConvDelta(sysb8 *clk, ystm *sttm);
-
- /*
- * ysStrClock, ysStrDelta - format clock value
- *
- * DESCRIPTION
- * ysStrClock() converts a structured clock value to a canonical string
- * representation of the form: "Jul 10 03:14:30". The year is added if
- * year is TRUE. If fraction is not zero, it specifies the number of
- * decimal places that should be included to specify parts of a second.
- * For instance, a value of three will include milliseconds. Values less
- * than zero or greater than six are reduced to either zero or six, whichever
- * is closer. The full form is: "Jul 10 03:14:30.123456 1965". The value
- * is written into the buf parameter, which must be a minimum size of
- * YSTM_BUFLEN.
- *
- * ysStrDelta() converts a structured clock value to a canonical string
- * representation of the form: "sdddd hh:mm:ss.ffffff". The field "sdddd"
- * is the signed number of days represented by the delta. If the sign is
- * positive, a blank is used. The number of fractional digits is
- * indicated by fraction, using the same rules as for ysStrClock(). The
- * value is written into the buf parameter, which must be a minimum size
- * of YSTM_BUFLEN.
- *
- * WARNINGS
- * ysStrClock() is not sensitive to locale.
- */
- #define YSTM_BUFLEN 32
- char *ysStrClock(char *buf, ystm *sttm, boolean year, sword fraction);
- char *ysStrDelta(char *buf, ystm *sttm, sword fraction);
-
- EXTC_END
- #endif /* YSTM_ORACLE */
-