-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(changetracking): move timestamp millisecond function to help…
…ers/utils
- Loading branch information
1 parent
afea6a0
commit b6f4019
Showing
3 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
package changetracking | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/newrelic/newrelic-client-go/v2/pkg/nrtime" | ||
"github.com/newrelic/newrelic-client-go/v2/internal/utils" | ||
) | ||
|
||
// DO NOT DELETE the following function - this is not covered by Tutone | ||
// but is needed to ensure proper conversion of timestamps | ||
func (input *ChangeTrackingDeploymentInput) CorrectTimestampMilliseconds() { | ||
inputTimestamp := input.Timestamp | ||
timestamp := time.Time(inputTimestamp) | ||
|
||
// since time.Time in Go does not have a milliseconds field, which is why the implementation | ||
// of unmarshaling time.Time into a Unix timestamp in the serialization package relies on | ||
// nanoseconds to produce a value of milliseconds, we try employing a similar logic below | ||
|
||
if timestamp.Nanosecond() < 100000000 { | ||
timestamp = timestamp.Add(time.Nanosecond * 100000000) | ||
} | ||
|
||
input.Timestamp = nrtime.EpochMilliseconds(timestamp) | ||
timestamp := utils.GetSafeTimestampWithMilliseconds(inputTimestamp) | ||
input.Timestamp = timestamp | ||
} |