views:

121

answers:

3

In our code, we have a 16-byte packed struct that we call "ISOTIME":

typedef struct isotime {
    struct {
        uint16_t iso_zone : 12; // corresponding time zone
        uint16_t iso_type : 4; // type of iso date
    } iso_fmt;

    int16_t iso_year; // year
    uint8_t iso_month; // month
    uint8_t iso_day; // day
    uint8_t iso_hour; // hour
    uint8_t iso_minute; // minute
    uint8_t iso_second; // second
    uint8_t iso_centi; // centi-second
    uint8_t iso_hundred; // hundreds of micro-seconds
    uint8_t iso_micro; // micro-seconds
    uint32_t iso_unused; // pad out to 16 bytes
} ISOTIME;

I'm trying to figure out what standard that this is supposed to be implementing. Anyone have a clue? My Google-fu is failing me.

+1  A: 

Looks like a structure to handle ISO 8601 - the format depends on how the data is displayed:

20030103 = Basic Format
20030103T0700-0500 = Basic Format w/ Time and Zone
2003-01-03 = Extended Format
Gary.Ray
We use it to convert to and from ISO 8601, but the people who implemented it first (possibly in 1995) are no longer with the company, and we're pretty sure that there's some standard that indicates a 16-byte packed binary structure but we can't find it. ISO 8601 is concerned with textual representations, not binary in-memory representations, so far as I can tell (having read ISO 8601:2004 this morning).
Austin Ziegler
Older IBM computers used to have a 16-Byte Packed Integer standard. Could it be from that?
Gary.Ray
This may be it - http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0925083170.htm
Gary.Ray
+2  A: 

As Gary Ray says, the main standard for interchange of date and time data is ISO 8601:2004.

The data structure shown can handle the standard Gregorian calendar with time resolution to microseconds.

There are other standards of relevance - ISO/IEC 9899:1999 (C) for example. It defines a different structure and specifies the encoding of years (year number - 1900 is stored in the tm_year element, for example; also, month numbers run from 0 for January to 11 for December - good for indexing into an array of month names but lousy otherwise). POSIX (ISO/IEC 9945-1:2008) inherits its time handling from the C standard. SQL (ISO/IEC 9075-2:2008) works more closely with ISO 8601 than with C/POSIX. But the structure shown could be used in any of these environments - though it is not standard in the C/POSIX environment.

Jonathan Leffler
+2  A: 

International standards rarely concern themselves with detailed in-memory representations of data , particularly at the bit level (exceptions of course for floating point standards). This is because such things are inherently unportable. That's not to say that there is no standard for this structure, but I think it unlikely.

anon