tpf_timet_to_STCKE: Convert time_t to tpf_TOD_ext_type
This function converts a time_t value to its corresponding z/TPF extended time-of-day (TOD) clock timestamp.
Last updated
Added in 2023.
Format
#include <tpf/c_stcke.h>
int tpf_timet_to_STCKE(time_t t_in, tpf_TOD_ext_type* tod_out);
- t_in
- The time_t value.
- tod_out
- A pointer to the output tpf_TOD_ext _type data structure. The result of the conversion will be written at this location.
Normal return
A value of STCKE_CNV_OK or 0 is returned.
Error return
| Return label | Return value | Description |
|---|---|---|
| STCKE_CNV_OOB | -1 | The specified t_in value is less than -2208988800. |
| STCKE_CNV_NULL | -2 | The specified tod_out value is a null pointer. |
Programming considerations
- The first byte of the tpf_TOD_ext_type data structure, which represents the epoch, is also populated, so time_t values that represent timestamps beyond 2042-09-17 23:53:47 are converted to the correct tpf_TOD_ext_type values.
- This function does not produce a timestamp before 1900-01-01.
Examples
The following example converts a time_t value to its corresponding extended TOD clock
value.
#include <tpf/c_stcke.h>
#include <sys/time.h>
tpf_TOD_ext_type tod_out;
time_t t_in;
t_in = time(NULL);
tpf_timet_to_STCKE(t_in, &tod_out);