libsdfio 1.0.0
Reader and writer for ISO 25178-71 SDF surface data files in C
Loading...
Searching...
No Matches
sdfio_time_zone Struct Reference

Conversion of the dates of ISO-1.0 files between the local clock of the writer and UTC. More...

#include <types.h>

Data Fields

void * user
 Opaque pointer passed as the first argument of both callbacks.
time_t(* local_to_utc )(void *user, const sdfio_date *local)
 Converts the clock reading local of a file to the UTC time.
bool(* utc_to_local )(void *user, time_t utc, sdfio_date *local)
 Converts the UTC time utc to the clock reading to store, and returns it in local.

Detailed Description

Conversion of the dates of ISO-1.0 files between the local clock of the writer and UTC.

These files store a clock reading without a time zone. ISO-2.0 files store UTC and are not affected. A callback that is null performs no conversion, and the clock reading is used as if it were UTC.

On a system where the C library knows the zone, use sdfio_system_time_zone() and not an own conversion. Own callbacks are for a zone that the C library does not know, such as the fixed clock of a device.

The conversion of a reading that occurs twice, or not at all, when the clocks change is the decision of the callback. The result is correct only if the zone of the callbacks is the zone in which the file was written, which the file does not record. The callbacks are called by the thread that uses the handle. Without an initializer, call sdfio_time_zone_init() before assigning fields.

The structure is frozen for the major version: it has these three fields and a new property of a time zone is a new function.

Examples
custom_timezone.c.

Field Documentation

◆ local_to_utc

time_t(* sdfio_time_zone::local_to_utc) (void *user, const sdfio_date *local)

Converts the clock reading local of a file to the UTC time.

Called when a reader parses a date. Returns SDFIO_NO_TIME if it cannot convert the reading, and the date then reads as not recorded.

◆ utc_to_local

bool(* sdfio_time_zone::utc_to_local) (void *user, time_t utc, sdfio_date *local)

Converts the UTC time utc to the clock reading to store, and returns it in local.

Called when a writer formats a date. Returns false if it cannot convert the time, and the file cannot be created.


The documentation for this struct was generated from the following file:
  • /home/runner/work/libsdfio/libsdfio/include/sdfio/types.h