-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax: Datetime, URI, CID, TID #360
Conversation
atproto/syntax/tid.go
Outdated
} | ||
|
||
// Constructs a new TID from a UNIX timestamp (in milliseconds) and clock ID value. | ||
func NewTID(unixMilis int64, clockId uint) TID { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should take a time.Time
and extract the milliseconds for us. Thinking about the calling conventions here and Go doesn't really deal with millisecond time often.
Also is this Microseconds or milliseconds? The usage below implies this is Microseconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch on the millis/micros, I fixed the behavior but didn't remember to update the variable names (or a test call).
I added NewTIDFromTime
. I'd be open to renaming and have NewTID
take a time and rename the existing to NewTIDFromUnixMicros
(eg). I think it is fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, there may be some iteration as we start using these but looks good!
More of these parse helpers.
Datetime
is the main thing here, with a bunch of test cases.TID is also helpful, and a bunch of little interop issues came up when implementing this.
The CID and URI ones are a bit weird. URIs aren't very well spec'd in a general/abstract sense, and for CIDs we already have
go-cid
which is what would normally be used. But I think it is good to have string-only validation that ensures exact pass-through, and can be used as a type signature.Questions for review: