【问题标题】:What standard does this "ISOTIME" structure represent?这个“ISOTIME”结构代表什么标准?
【发布时间】:2009-05-21 16:57:16
【问题描述】:

在我们的代码中,我们有一个 16 字节的压缩 struct,我们称之为“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; 

我试图弄清楚这应该实施什么标准。有人有线索吗?我的 Google-fu 让我失望了。

【问题讨论】:

    标签: c++ datetime data-structures timezone


    【解决方案1】:

    国际标准很少关注数据在内存中的详细表示,尤其是在位级别(浮点标准当然例外)。这是因为这样的东西本质上是不可移植的。这并不是说这种结构没有标准,但我认为不太可能。

    【讨论】:

      【解决方案2】:

      正如 Gary Ray 所说,日期和时间数据交换的主要标准是 ISO 8601:2004。

      显示的数据结构可以处理时间分辨率为微秒的标准公历。

      还有其他相关标准 - 例如 ISO/IEC 9899:1999 (C)。它定义了不同的结构并指定了年份的编码(例如,年份编号 - 1900 存储在 tm_year 元素中;此外,月份编号从一月的 0 到十二月的 11 - 适合索引到月份名称数组,但否则很糟糕)。 POSIX (ISO/IEC 9945-1:2008) 继承了 C 标准的时间处理。 SQL (ISO/IEC 9075-2:2008) 与 ISO 8601 的合作比与 C/POSIX 的合作更紧密。但是显示的结构可以在任何这些环境中使用——尽管它在 C/POSIX 环境中不是标准的。

      【讨论】:

        【解决方案3】:

        看起来像处理 ISO 8601 的结构 - 格式取决于数据的显示方式:

        20030103 = Basic Format
        20030103T0700-0500 = Basic Format w/ Time and Zone
        2003-01-03 = Extended Format 
        

        【讨论】:

        • 我们使用它来转换和转换 ISO 8601,但首先实施它的人(可能是在 1995 年)不再在公司工作,我们很确定有一些标准表明一个 16 字节的打包二进制结构,但我们找不到它。据我所知,ISO 8601 关注的是文本表示,而不是内存中的二进制表示(今天早上阅读了 ISO 8601:2004)。
        • 旧的 IBM 计算机曾经有一个 16 字节的压缩整数标准。会不会是这样的?
        猜你喜欢
        • 1970-01-01
        • 2010-12-16
        • 1970-01-01
        • 1970-01-01
        • 2021-04-08
        • 2012-03-02
        • 2014-06-20
        • 2017-08-28
        • 1970-01-01
        相关资源
        最近更新 更多