Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Representing Fraction of Second with ISO 8601:2004

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’)

like image 454
Maanu Avatar asked Sep 15 '14 07:09

Maanu


People also ask

How do I read the ISO 8601 date format?

ISO 8601 represents date and time by starting with the year, followed by the month, the day, the hour, the minutes, seconds and milliseconds. For example, 2020-07-10 15:00:00.000, represents the 10th of July 2020 at 3 p.m. (in local time as there is no time zone offset specified—more on that below).

How do I specify the duration in an ISO 8601 format?

Briefly, the ISO 8601 notation consists of a P character, followed by years, months, weeks, and days, followed by a T character, followed by hours, minutes, and seconds with a decimal part, each with a single-letter suffix that indicates the unit. Any zero components may be omitted.

Is ISO 8601 always UTC?

The toISOString() method returns a string in simplified extended ISO format (ISO 8601), which is always 24 or 27 characters long ( YYYY-MM-DDTHH:mm:ss. sssZ or ±YYYYYY-MM-DDTHH:mm:ss. sssZ , respectively). The timezone is always zero UTC offset, as denoted by the suffix Z .

What is Z ISO 8601?

Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "T0930Z". "14:45:15 UTC" would be "14:45:15Z" or "T144515Z". The Z suffix in the ISO 8601 time representation is sometimes referred to as "Zulu time" because the same letter is used to designate the Zulu time zone.


1 Answers

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
like image 96
chansen Avatar answered Nov 24 '22 15:11

chansen