Skip to content

feat: time.Time as unix milliseconds - #10

Merged
MarkRosemaker merged 1 commit into
masterfrom
feat/unix-milli
Nov 25, 2026
Merged

MarkRosemaker merged 1 commit into
masterfrom
feat/unix-milli

Conversation

@MarkRosemaker

Copy link
Copy Markdown
Owner

This is the first step of openapi-codegen's "Unix times in milliseconds" roadmap entry. go-api-libs/ibkr's trades recording sends trade_time_r as Unix milliseconds, such as 1795464914000, and its portfolio summary does the same with timestamp.

New helpers, beside TimeMarshalIntUnix and TimeUnmarshalIntUnix, which handle seconds:

  • TimeMarshalIntUnixMilli / TimeUnmarshalIntUnixMilli write and read a time.Time as an integer of Unix milliseconds, keeping the milliseconds. The zero time is 0, as with seconds.
  • TimeMarshalIntUnixMilliFor(names...) / TimeUnmarshalIntUnixMilliFor(names...) do so only for the object members named, or arrays they hold, as the seconds' For variants do. A document can then mix times in milliseconds, in seconds and in time.Time's own form.

openapi-codegen is to use these for a date-time-ms format.

Test: TestUnixMilliTime round-trips a struct with times in milliseconds (one in an array), one in seconds and two in RFC 3339. It checks that the milliseconds survive and that the zero time writes as 0. It also reads a bare number with the unnamed helper.

make ready passes.


Generated by Claude Code

TimeMarshalIntUnixMilli and TimeUnmarshalIntUnixMilli write and read a time
as an integer of unix milliseconds, the zero time as 0, as
TimeMarshalIntUnix does seconds; their For variants do so for the members
named, beside times in seconds and in the type's own form. openapi-codegen is
to use them for its date-time-ms format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
@MarkRosemaker
MarkRosemaker merged commit 3f67f86 into master Nov 25, 2026
1 check passed
@MarkRosemaker
MarkRosemaker deleted the feat/unix-milli branch November 25, 2026 19:16
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