Repository navigation
feat: time.Time as unix milliseconds - #10
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ras Unix milliseconds, such as1795464914000, and its portfolio summary does the same withtimestamp.New helpers, beside
TimeMarshalIntUnixandTimeUnmarshalIntUnix, which handle seconds:TimeMarshalIntUnixMilli/TimeUnmarshalIntUnixMilliwrite and read atime.Timeas an integer of Unix milliseconds, keeping the milliseconds. The zero time is0, as with seconds.TimeMarshalIntUnixMilliFor(names...)/TimeUnmarshalIntUnixMilliFor(names...)do so only for the object members named, or arrays they hold, as the seconds'Forvariants do. A document can then mix times in milliseconds, in seconds and intime.Time's own form.openapi-codegen is to use these for a
date-time-msformat.Test:
TestUnixMilliTimeround-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 as0. It also reads a bare number with the unnamed helper.make readypasses.Generated by Claude Code