Checking fractional timestamp precision in this parser
This timestamp parser reads up to three fractional-second digits and rejects anything longer. The worksheet measures a half-second interval and then shows what happens when a fourth digit appears.
What the parser accepts
The time duration calculator reads two RFC 3339 style timestamps, each with an explicit Z or numeric offset, and subtracts them to give an elapsed time. Fractional seconds are allowed, but only up to three digits, which is millisecond resolution. A value like 00:00:00.125Z is accepted. A value like 00:00:00.1250Z has four fractional digits, and the parser rejects it with a message that at most three digits are allowed. The rejection is deliberate. A silent cut to three digits would discard information the source recorded, and a silent round would alter it. By refusing, the tool forces a decision by the person who knows what the extra digits mean. This is a safer failure than a quietly wrong duration.
A half-second example
Take a start of 2026-10-19T00:00:00.125Z and an end of 2026-10-19T00:00:00.625Z on the same date. Both fractions are multiples of one millisecond, with 125 and 625 milliseconds. The difference is 625 minus 125, or 500 milliseconds, which is 0.5 second. The calculator reports a duration of 0.5 seconds, and since the interval is under a minute the day, hour and minute parts are zero. The trailing Z means the times are in UTC, so no time zone offset enters the subtraction. Because 0.5 is a dyadic fraction, it has an exact binary representation, which is why this particular result is clean. Other decimal differences can display tiny residuals from binary floating point.
Equivalent value, different spelling
The text .1250 and the text .125 name the same mathematical fraction, one eighth of a second. The parser still treats them differently, because it validates the written representation and not only the number it implies. That strictness is common in data validation. A format specification defines which strings are valid, and a string that carries more digits than the specification allows is invalid even if trimming it would produce an acceptable value. Trailing zeros are the harmless case, but the same rule would also reject .1251, where trimming would change the value. A single rule that handles both cases the same way is simpler and more predictable than one that tries to guess when extra digits are meaningful.
Where higher precision comes from
Many systems record time below the millisecond. Microsecond timestamps appear in database logs, and nanosecond counts appear in operating system clocks and in tracing systems. Programming libraries differ in what they emit. Some write six fractional digits, others nine, and some drop trailing zeros while others keep them. A log exported from one system and pasted here may therefore carry more digits than the parser accepts. The rejection is a signal that the data come from a higher-resolution source. Before shortening anything, find out whether sub-millisecond differences matter for the question at hand, because for a duration measured in hours, microseconds are irrelevant, while for a latency measurement they might be the entire point.
Converting with a documented rule
If you decide that millisecond resolution is enough, convert on purpose and write the rule down. Truncation drops digits beyond the third, so .1259 becomes .125. Rounding to the nearest millisecond turns .1259 into .126. These differ, and over many records the choice can bias results in one direction. Pick one, apply it consistently, and keep the original string next to the converted one. For a four-digit value like .1250, either rule gives .125 and no information is lost. For .1251, truncation gives .125 and rounding also gives .125, but for .1256 truncation gives .125 while rounding gives .126. The difference is one millisecond, which is small but not zero.
A second interval, longer than a minute
Consider a start of 2026-10-19T08:15:30.250Z and an end of 2026-10-19T08:17:45.750Z. The clock reading advances from 08:15:30.250 to 08:17:45.750, which is 2 minutes plus 15.500 seconds, or 135.5 seconds in total. The calculator reports the elapsed time as total seconds, so it returns 135.5. The values are illustrative. Each timestamp here uses three fractional digits, so both are accepted. If either had been written with six digits, such as .250000Z, the parser would refuse it, even though .250000 equals .250 numerically.
The end must not precede the start
The calculator subtracts the start from the end and does not accept an end that precedes the start. Swapping the worksheet pair, so that the start is 00:00:00.625Z and the end is 00:00:00.125Z, returns an error that the end timestamp must not precede the start, and no negative duration is shown. The error usually means the fields were swapped, or that two events were logged in a different order from the one assumed. Check which event really came first in the question you are answering. For a signed difference, such as an actual time compared with a scheduled one that may have been early, decide the sign yourself from which timestamp is earlier, then enter the earlier one as the start.
Why records should keep source precision
A rejected value is a prompt to preserve the original record. If a pipeline normalizes timestamps to milliseconds, store the raw string in a separate field so that nothing is permanently lost. Later requirements often turn out stricter than expected. A forensic review, a reconciliation between two systems, or an ordering of events that happened within the same millisecond all need the digits that a coarse format discards. Two events that differ by 400 microseconds will compare as simultaneous after truncation to milliseconds, and their true order cannot be recovered. Keeping both the original and the converted value costs a few bytes per record and removes that risk.
Floating-point residuals in the output
Durations are computed from numeric epoch seconds, which are stored as binary floating-point numbers. A fraction like 0.125 is exactly representable because it is a power of two, but a fraction like 0.1 is not. Subtracting two timestamps on the same date whose fractions are .100 and .300 returns 0.20000004768371582 from this calculator, not exactly 0.2. This is a feature of how computers store most decimal fractions, not an error in the parser. When you compare outputs, allow a tolerance of about a microsecond, or work in integer milliseconds if exact equality matters. The half-second example in this worksheet is exact because 0.125 and 0.625 are both sums of powers of two.
The standards do not set this limit
The three-digit rule belongs to this parser and not to the date and time formats it reads. RFC 3339, the Internet profile of ISO 8601, defines the fractional part of the seconds field as a decimal point followed by one or more digits, with no fixed maximum. ISO 8601 itself leaves the number of decimal places to agreement between the parties exchanging data. A timestamp with six or nine fractional digits can therefore be perfectly valid in the wider world and still be refused here. Knowing that the limit is a tool setting changes the next step. The data are not malformed. They simply carry more resolution than this particular calculator is built to read.
Units below the second
The International System names the prefixes used for fractions of a second. A millisecond is one thousandth of a second, a microsecond is one millionth and a nanosecond is one billionth. Three fractional digits therefore correspond to milliseconds, six to microseconds and nine to nanoseconds. The JavaScript Date object has millisecond resolution, which is one reason three digits are a common practical limit in web tools. Many databases store microseconds, and operating system clocks and tracing tools often report nanoseconds. Matching the digit count to the unit is a quick way to recognize where a pasted timestamp came from.
Rounding can carry into the next second
Shortening a timestamp by rounding has a boundary case that truncation avoids. Take a time of 12:00:00.9996. Rounded to three digits it becomes 12:00:01.000, so the seconds field changes and any minute or hour boundary nearby can change too. A time of 23:59:59.9996 would round into the next day. Truncation of the same values gives 12:00:00.999 and 23:59:59.999, with no carry. Both rules are defensible, but they can disagree on which calendar second an event belongs to. If the record will be grouped by second, minute or day, decide the rule before converting, because events near a boundary can land in different groups depending on that choice.
Checking a pair of records before trusting a duration
A short routine prevents silent mistakes. First, confirm that both timestamps use the same time zone designator, since the examples here end in Z for UTC. Second, count the fractional digits in each and note whether either exceeds three. Third, decide whether the difference you need is larger than the resolution you will keep. A duration of 0.5 seconds measured at millisecond resolution carries an uncertainty of about a millisecond at each end, which is irrelevant for a half second but could matter for an interval of five milliseconds. Fourth, keep the original strings. After those checks, the calculator result is a reliable description of the supplied timestamps.
Stating the precision of a reported duration
A duration is only as precise as its inputs. If both timestamps were truncated to milliseconds, report the interval to the nearest millisecond and say so. Writing 0.500 seconds states a resolution that 0.5 does not, and it also warns readers that the source recorded three digits. When the original data had more digits and you shortened them, mention the rule used. These details cost a few words in a report and save a later reader from guessing whether the figure was rounded, truncated or measured to that resolution.
Reproduce the checks
Supported fractions
Open the Time Duration Calculator and enter:
- Start
2026-10-19T00:00:00.125Z- End
2026-10-19T00:00:00.625Z
Expected output:
Seconds
0.5Both fractions are millisecond-aligned.
Four fractional digits
Open the Time Duration Calculator and enter:
- Start
2026-10-19T00:00:00Z- End
2026-10-19T00:00:00.1250Z
Expected rejection:
at most three fractional digitsThe parser rejects the representation rather than reducing its precision.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08