最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

network programming - Is there an ISO format which defines timezone aware datetime values with nanosecond precision? - Stack Ove

programmeradmin2浏览0评论

I am aware of ISO 8601, which I believe defines a format for exchange of string formatted timezone aware datetime values with a precision of either seconds, or milliseconds.

The milliseconds component may be an extension to the standard of some kind, as it seems to be that there is some variability in support for this across various different software libraries. (I may be mistaken about this. Either way, this standard does not specify microseconds or nanoseconds resolution.)

Are there any other ISO standards which support resolution to microseconds, or preferably, nanoseconds?

I am aware of ISO 8601, which I believe defines a format for exchange of string formatted timezone aware datetime values with a precision of either seconds, or milliseconds.

The milliseconds component may be an extension to the standard of some kind, as it seems to be that there is some variability in support for this across various different software libraries. (I may be mistaken about this. Either way, this standard does not specify microseconds or nanoseconds resolution.)

Are there any other ISO standards which support resolution to microseconds, or preferably, nanoseconds?

Share Improve this question edited 16 hours ago VLAZ 29k9 gold badges62 silver badges83 bronze badges asked yesterday user28464084user28464084 335 bronze badges 2
  • 1 What makes you think that ISO 8601 limits the number of decimal digits to three? I don't think it's ever had such a limit, and the current standard certainly doesn't impose any limit on the precision. Relevant quotes: "a decimal fraction of hour, minute or second may be included" and "The interchange parties, dependent upon the application, shall agree the number of digits in the decimal fraction." – Toby Speight Commented yesterday
  • @TobySpeight I guess because the software tools I am using have this limit, and those tools say "supports ISO 8601". – user28464084 Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 1

NO, ISO 8601 IS the ISO standard for date and time.

The standard allows for any number of decimal places and describes how to interpret the value if some optional elements are omitted.

There is no limit on the number of decimal places for the decimal fraction. However, the number of decimal places needs to be agreed to by the communicating parties.

(I may be mistaken about this. Either way, this standard does not specify microseconds or nanoseconds resolution.)

Yes, you are mistaken ;) micro and nano seconds are expressed as fractions of seconds.

  • 1 micro second : 0.000001
  • 1 nano second: 0.000000001

Support for different levels of precision in implementation is traditionally restricted by the underlying storage structure used by the application. Even if you sent a value with 7 decimal places, if the application can only store 3, then the value will either be truncated, rounded or the application will fail.

It is up to your application to handle this and to choose the correct storage precision to support the unit of time that you want to measure.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论