Skip to content

feat: date-time-ms, a time.Time in unix milliseconds - #89

Merged
MarkRosemaker merged 2 commits into
mainfrom
feat/date-time-ms
Nov 25, 2026
Merged

MarkRosemaker merged 2 commits into
mainfrom
feat/date-time-ms

Conversation

@MarkRosemaker

@MarkRosemaker MarkRosemaker commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

This does the roadmap entry "Unix times in milliseconds". An integer of format date-time-ms, such as 1795464914123, is now a time.Time to the millisecond. go-api-libs/ibkr's trades (trade_time_r) and portfolio summary (timestamp) are the first recordings with such values.

How it's written and read

  • In a body: through jsonutil's TimeMarshalIntUnixMilli / TimeUnmarshalIntUnixMilli, as date-time integers use the seconds helpers.
    • Where every time in a document is in milliseconds, one marshaler for time.Time writes them all.
    • Where other forms are about, the For variants name the members holding milliseconds, as for seconds. The golden spec does this: seenAt sits beside at in seconds and string times.
  • In a query parameter: the client sends strconv.FormatInt(v.UnixMilli(), 10), and the server parses with time.UnixMilli.
  • In a generated test's literal: a recorded value becomes its time, rather than being read as seconds.

Changes

  • ir:
    • FormatDateTimeMs maps to time.Time, with isUnixMilli beside isUnix, which now leaves the format out.
    • Field.IsUnixMilli and Param.IsUnixMilli, a third encoding in markEncodings, and Document.HasUnixMilliTimeFields / UnixMilliTimeMembers.
  • types.gen.go.tmpl registers the helpers. interactions.go turns recorded milliseconds into their time for a literal.
  • Golden spec: a seen query parameter and a DateWrapper.seenAt member of the format. I generated to a scratch directory and read the diff before applying it to api.js, client.gen.go, server.gen.go, types.gen.go and ir.json; it holds only the new parameter and member.
  • Hand-written test: unix_test.go checks that seenAt is written as 1795464914123 and reads back to the same instant.
  • Docs: README/features.md describes it, and the roadmap entry goes.
  • Bumped dependencies: openapi and jsonutil move to their master, which have the format (feat: the date-time-ms format, a time in unix milliseconds openapi#33) and the helpers (feat: time.Time as unix milliseconds jsonutil#10).

make ready passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y

An integer of format date-time-ms is a time.Time to the millisecond, written
and read as unix milliseconds through jsonutil's TimeMarshalIntUnixMilli and
TimeUnmarshalIntUnixMilli, or their For variants by member name where a
document holds times of other forms too, as for unix seconds. A query
parameter of the format is sent as UnixMilli and parsed with time.UnixMilli,
and a recorded value becomes its time in a generated literal. The golden spec
gains a query parameter and a DateWrapper member of the format; the roadmap
entry goes.

openapi and jsonutil are pinned to the commits that bring the format and the
helpers, until MarkRosemaker/openapi#33 and MarkRosemaker/jsonutil#10 merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
@MarkRosemaker
MarkRosemaker merged commit cf9b578 into main Nov 25, 2026
1 check passed
@MarkRosemaker
MarkRosemaker deleted the feat/date-time-ms branch November 25, 2026 19:36
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.

2 participants