How do libraries in different programming languages handle Date & Time, Timestamps & Durations, Leapseconds & -years, DSTs & Timezones, …?

前端 未结 6 1746
夕颜
夕颜 2020-12-24 02:27

Is there a standard body or a specific normative way how time-related things should be implemented in practice (like ICU for Unicode-related tasks) or is this curre

6条回答
  •  生来不讨喜
    2020-12-24 03:07

    I don't think there's a single standard to such things at the moment, however there are multiple standards which such things may conform to: ISO 8601 for example.

    ICU's own date/time handling is a cross-language (C/C++ and Java) and multi-platform library.

    It handles dates and times internally, typically, using for a single time a UDate (C/C++) or a java.util.Date/long (Java), as number of milliseconds since 1-1-1970, or a Calendar object which is specific to the type of calendar (Gregorian vs Hijri, etc). Durations are available for formatting. Leap years are calculated as part of calendar systems, and leap seconds are assumed to be handled by the underlying operating system. DST/Timezone data is kept up to date with 'the tz database' sometimes referred to by its author's surname, Olson.

    Hope this has answered your question some as regards ICU.

提交回复
热议问题