Support for struct tm temporal structures

In addition to supporting time_t, the data type helper API also supports the common C++ struct tm structure. Date and Timestamp values can be converted to a tm; however, Time and TimeTz values cannot because there is no date information included in those values.

The API uses the strict implementation of struct tm which does not contain the additional fields tm_zone and tm_gmtoff, commonly seen in GCC. The strict implementation is necessary for consistency between the host and SPU C++ libraries. The API provides functions for conversions between struct tm and the Netezza Performance Server Date and Timestamp data types. Since struct tm uses more fields than are needed to store Date or Timestamp information, several fields are ignored by conversion. The following table lists the mappings between tm fields and their Netezza Performance Server data type counterparts.

Table 1. Examples of struct tm and Netezza Performance Server data type properties
struct tm fields Data used by NZ DATE Data used by NZ TIMESTAMP
tm_sec (0 - 61) Ignored Seconds (0 - 59)
tm_min (0 - 59) Ignored Minutes
tm_hour (0 - 23) Ignored Hours
tm_mday (1 - 31) day of the month Day Day
tm_mon (0 - 11) months since January Month Month
tm_year since 1900 Year Year
tm_wday (0 - 6) week day Week Day Week Day
tm_yday (0 - 365) day of the year Year Day Year Day
tm_isdst daylight savings time flag Set to -1 Set to -1

For conversions to and from struct tm, Netezza Performance Server does not use or support leap seconds. Thus, the seconds fields of struct tm that are written out by the API never exceed 59. If a conversion routine is called with a struct tm containing a 60 or 61 tm_sec field, the API throws an error.

When you are encoding from a struct tm format, ignored fields can contain any data. When you are decoding to a struct tm, the ignored fields have a value of zero.

The tm_isdst flag is ignored on input and is set to -1 for 'unknown' on output. Setting tm_isdst to -1 is not within the standard, but is a typical industry practice. In all other respects, the API conforms to all the time_t specifications as listed in the ANSI C++ standard.