ISO Time with Microseconds
datetime.time.isowas datetime.time in v124-hour time with microsecond precision. Common in high-frequency data, scientific instruments, and log files.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As TIME |
|---|---|
| 10:30:00.123456 | 10:30:00.123456 |
| 23:59:59.000000 | 23:59:59 |
- %H
- hour, 24-hour clock
- %M
- minutes
- %S
- seconds
- %f
- fractional seconds
Shape
Length 10 to 18 characters.
^\d{2}:\d{2}:\d{2}\.\d{1,9}$| Value | Length | Shape |
|---|---|---|
| 10:30:00.123456 | 15 | matches |
| 23:59:59.000000 | 15 | matches |
| 10.30:00.123456 | 15 | rejected: separator swapped |
Background
Origin
ISO 8601 is maintained by the International Organization for Standardization and was first published in 1988.[1] ISO 8601 writes a time of day in its extended format as hh:mm:ss, with colons between the hours, minutes and seconds.[1] ISO 8601 allows a decimal fraction to be added to the lowest order time element of a time representation.[1] ISO 8601 accepts either a comma or a full stop as the decimal mark between the seconds and their fraction.[1] ISO 8601:2004 preferred the comma as the decimal mark.[1] ISO 8601 sets no limit on the number of decimal places, but the number of decimal places needs to be agreed by the communicating parties.[1]
RFC 3339 grammar writes a partial time as hour, minute and second separated by colons, optionally followed by a full stop and one or more digits of fractional seconds.[2] RFC 3339 describes fractions of a second as its only rarely used option.[2]
Use
Python's datetime library defines the %f directive as the microsecond as a decimal number, zero-padded to 6 digits.[3] Python's time.isoformat writes HH:MM:SS.ffffff when the microsecond is not 0, and HH:MM:SS when it is 0.[3] Python's strptime accepts from one to six digits for %f and zero pads them on the right.[3] Python's time.fromisoformat accepts fractional seconds with any number of digits, truncating anything beyond 6.[3]
PostgreSQL's time type stores a time of day with a resolution of 1 microsecond.[4] PostgreSQL allows a precision of 0 to 6 fractional digits in the seconds field of a time value.[4] DuckDB's TIME type holds the hour, minute, second and microsecond of a day, and a separate TIME_NS type holds nanosecond precision.[5] DuckDB's documentation recommends that most applications use the TIMESTAMP types, keeping TIME for rare cases where the date part can be disregarded.[5] Before casting values with more than six fractional digits to a microsecond type, decide whether the extra precision matters to you. (Meridian's view) A time of day with no date or offset cannot be placed on a timeline by itself, so look for a companion date column and a stated time zone before treating these values as moments. (Meridian's view)
Sources
- [1]ISO 8601secondary source
- [2]RFC 3339: Date and Time on the Internet: Timestamps | RFC Editorstandard
- [3]datetime — Basic date and time types — Python 3.15.0 documentationdocumentation
- [4]PostgreSQL: Documentation: 18: 8.5. Date/Time Typesdocumentation
- [5]Time Types – DuckDBdocumentation
Detection notes
v1 name: datetime.time
Use it
$ finetype infer -i "10:30:00.123456" --mode column
→ datetime.time.iso
SELECT ft_infer('10:30:00.123456');
-- → 'datetime.time.iso'strptime({col}, '%H:%M:%S.%f')::TIME
-- Format: %H:%M:%S.%fSchema
https://meridian.online/schemas/datetime.time.iso · Frictionless type time · %H:%M:%S.%f
finetype taxonomy datetime.time.iso -o json-schema