-
Notifications
You must be signed in to change notification settings - Fork 106
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
Implement SDFC date <-> Go time type #62
Conversation
CreatedById string `force:",omitempty" json:",omitempty"` | ||
LastModifiedDate string `force:",omitempty" json:",omitempty"` | ||
LastModifiedDate *Time `force:",omitempty" json:",omitempty"` |
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.
These have to be pointers rather than embedded structs for omitempty
to be respected.
) | ||
|
||
const SFTIMEFORMAT1 = "2006-01-02T15:04:05.000-0700" | ||
const SFTIMEFORMAT2 = "2006-01-02T15:04:05.999Z" |
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.
const SFTIMEFORMAT2 = "2006-01-02T15:04:05.999Z" | ||
|
||
// Represents a SFDC Date. Implements marshaling / unmarshaling as a Go Time. | ||
type Time time.Time |
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.
There are pros and cons to this formulation vs.
type struct Time {
time.Time
}
Feedback welcome.
// Convenience Go time.Time converstion. | ||
func (t Time) Time() time.Time { | ||
return time.Time(t) | ||
} |
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.
This should possibly be:
func (t* Time) Time() time.Time {
if t == nil {
return time.Time{}
}
return time.Time(*t)
}
@nimajalali any interest in this? |
Is this project active? |
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.
@dragonsinth Thanks for the PR. I haven't been monitoring this repo closely but will go through it now.
I was hesitant to merge PRs before due to backward compatibility. Now that Go has go mod
for dependency management I feel better about merging PRs.
return nil | ||
} | ||
|
||
var _ forcejson.Unmarshaler = (*Time)(nil) |
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.
Are these required? What are they accomplishing?
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.
They're just compile time interface checks. We're verifying that the type implements custom json marshal/unmarshal.
sobjects/date_test.go
Outdated
package sobjects | ||
|
||
import ( | ||
"testing" |
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.
Minor but can we run goimports on this?
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!
updated and rebased |
@dragonsinth I fixed the test account and moved CI to github actions. Do you mind rebasing with master then we can merge? |
Re-rebased! |
Merged! Thx |
Awesome thanks! |
See #38