Skip to content
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

Merged
merged 2 commits into from
Aug 28, 2020

Conversation

dragonsinth
Copy link
Contributor

See #38

CreatedById string `force:",omitempty" json:",omitempty"`
LastModifiedDate string `force:",omitempty" json:",omitempty"`
LastModifiedDate *Time `force:",omitempty" json:",omitempty"`
Copy link
Contributor Author

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"
Copy link
Contributor Author

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
Copy link
Contributor Author

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)
}
Copy link
Contributor Author

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)
}

@dragonsinth
Copy link
Contributor Author

@nimajalali any interest in this?

@dragonsinth
Copy link
Contributor Author

Is this project active?

Copy link
Owner

@nimajalali nimajalali left a 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)
Copy link
Owner

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?

Copy link
Contributor Author

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.

package sobjects

import (
"testing"
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@dragonsinth
Copy link
Contributor Author

updated and rebased

@nimajalali
Copy link
Owner

@dragonsinth I fixed the test account and moved CI to github actions. Do you mind rebasing with master then we can merge?

@dragonsinth
Copy link
Contributor Author

Re-rebased!

@nimajalali nimajalali merged commit 1b4f54b into nimajalali:master Aug 28, 2020
@nimajalali
Copy link
Owner

Merged! Thx

@dragonsinth
Copy link
Contributor Author

Awesome thanks!

@dragonsinth dragonsinth deleted the datetime branch August 28, 2020 22:53
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