Representing Fraction of Second with ISO 8601:2004

老子叫甜甜 提交于 2019-12-05 01:48:57

问题


The following is the definition of IS0 8601:2004 standard. It says that the fraction of second can be represented with one to six digits.

Can I use all the 6 digits for representing the fraction of a second?
Are the following Representation correct, if I use 6 digits for representing fraction of a second?

1ms -- 001000
10ms -- 010000
100ms -- 100000

{Extended Time Format} (32 bytes)
YYYY-MM-DDThh:mm:ss.sTZD
YYYY = Year 0000 to 9999
MM = Month 01 to 12
DD = Day 01 to 31
T = special separator T
hh = Hour 00 to 23
mm = Minute 00 to 59
ss = Second 00 to 59
s = one to six digits representing a fraction of a second
TZD = time zone designator
(TZD is denoted by ‘+hh:mm’, ‘-hh:mm’ or‘Z’)


回答1:


ISO 8601:2004 doesn't specify the number of digits in the decimal fraction.

4.2.2.4 Representations with decimal fraction

The interchange parties, dependent upon the application, shall agree the number of digits in the decimal fraction. The format shall be [hhmmss,ss], [hhmm,mm] or [hh,hh] as appropriate (hour minute second, hour minute, and hour, respectively), with as many digits as necessary following the decimal sign. A decimal fraction shall have at least one digit.

Yes, your representation is correct if you use 6 digits for the decimal fraction.

1ms   -- 001000
10ms  -- 010000
100ms -- 100000
1μs   -- 000001


来源:https://stackoverflow.com/questions/25842840/representing-fraction-of-second-with-iso-86012004

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!