Skip to content

Prototype Int128 sub-nanosecond Timestamp periods - #4

Draft
quinnj wants to merge 1 commit into
mainfrom
prototype/subnanosecond-timestamps
Draft

quinnj wants to merge 1 commit into
mainfrom
prototype/subnanosecond-timestamps

Conversation

@quinnj

@quinnj quinnj commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

This demonstrates package-defined picoseconds, femtoseconds, and attoseconds using Timestamp{P}. It works with released Durations 1.3.0. The shared Timestamp support was merged in #6. This PR targets main and contains only the example, documentation, and example checks. No Timestamp implementation changes are included.

The 45-line example defines three 128-bit primitive periods and supplies their values, bounds, exact scales, and display. The same example works with Durations' compatibility implementation and with the updated Dates type in JuliaLang/julia#62994. Existing Timestamp methods provide construction, arithmetic, exact conversion, promotion/comparison, hashing, rounding, and ranges.

using Dates, Durations
include("examples/subnanosecond.jl")
using .Subnanosecond: Picosecond, Femtosecond

t = Timestamp{Picosecond}(2026, 9, 24)
x = t + Picosecond(1)
string(x)                          # "2026-09-24T00:00:00.000000000001"
x - t                              # Picosecond(1)
floor(x, Nanosecond) == t           # true
sizeof(x)                          # 16
Timestamp{Femtosecond}(x) + Femtosecond(1) - x  # Femtosecond(1)

The example is opt-in and adds no exports or dependencies. It uses BigInt rational intermediates for short, exact endpoint calculations; this is not a performance claim. It formats sub-nanosecond fractions but does not parse strings beyond nine digits. No timezone, Arrow wire-format, or release change is included.

Validation: all 167 example checks passed against a fresh registry installation of Durations 1.3.0 on Julia 1.13.0. They also passed with the updated Dates backend. Complete package suites also passed on Julia 1.10.12 and 1.13.0, and on Julia 1.14 with Dates loaded from the updated Julia PR checkout. CI covers the platform matrix and trim workload.

Co-authored by Codex

@quinnj
quinnj force-pushed the prototype/subnanosecond-timestamps branch from 64f373e to 8fe56bc Compare September 24, 2026 23:18
@quinnj
quinnj changed the base branch from main to timestamp-period-extensions September 24, 2026 23:19
@quinnj
quinnj force-pushed the prototype/subnanosecond-timestamps branch from 8fe56bc to 629478c Compare September 24, 2026 23:46
@quinnj
quinnj changed the base branch from timestamp-period-extensions to main September 24, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant