The datetime.h header file
The datetime.h header file contains definitions for use with the DATETIME and INTERVAL data types.
- The internal format represents DATETIME and mi_datetime values with the dtime_t structure.
- The internal format represents INTERVAL and mi_interval values with the intrvl_t structure.
| Name of macro | Description |
|---|---|
| TU_YEAR | The time unit for the YEAR qualifier field |
| TU_MONTH | The time unit for the MONTH qualifier field |
| TU_DAY | The time unit for the DAY qualifier field |
| TU_HOUR | The time unit for the HOUR qualifier field |
| TU_MINUTE | The time unit for the MINUTE qualifier field |
| TU_SECOND | The time unit for the SECOND qualifier field |
| TU_FRAC | The time unit for the leading qualifier field of FRACTION |
| TU_Fn | The names for mi_datetime ending fields of FRACTION(n), for n from 1 - 5 |
| TU_START(q) | Returns the leading field number from qualifier q |
| TU_END(q) | Returns the trailing field number from qualifier q |
| TU_LEN(q) | Returns the length in digits of the qualifier q |
| TU_FLEN(f) | Returns the length in digits of the first field, f, of an interval qualifier |
| TU_ENCODE(p,f,t) | Creates a qualifier from the first field number f with precision p and trailing field number t |
| TU_DTENCODE(f,t) | Creates an mi_datetime qualifier from the first field number f and trailing field number t |
| TU_IENCODE(p,f,t) | Creates an mi_interval qualifier from the first field number f with precision p and trailing field number t |
/* Use the variable that was declared intvl1. */
mi_interval intvl1;
...
/* Set the interval qualifier for the variable */
intvl1.in_qual = TU_IENCODE(2, TU_DAY, TU_SECOND);
...
/* Assign a value to the variable */
incvasc ("5 2:10:02", &intvl1);In the previous example, the mi_interval variable gets a day to second qualifier. The precision of the largest field in the qualifier, day, is set to 2.
In addition to the declaration of the dtime_t typedef and the preceding date and time macros, the datetime.h header file declares the DATETIME-type functions of the library. The mitypes.h header file automatically includes datetime.h. In turn, the milib.h header file automatically includes mitypes.h and mi.h automatically includes milib.h. Therefore, you automatically have access to the dtime_t and intrvl_t structures, the mi_datetime and mi_interval data types, any of the date or time macros, or any of the DATETIME-type functions when you include mi.h in your module.