github.com/newrelic/newrelic-client-go@v1.1.0/pkg/nrtime/types_func.go (about)

     1  package nrtime
     2  
     3  import (
     4  	"github.com/newrelic/newrelic-client-go/internal/serialization"
     5  )
     6  
     7  //
     8  // Functions created on auto-generated types
     9  //
    10  
    11  // MarshalJSON wrapper for EpochSeconds
    12  func (t EpochSeconds) MarshalJSON() ([]byte, error) {
    13  	return serialization.EpochTime(t).MarshalJSON()
    14  }
    15  
    16  // UnmarshalJSON wrapper for EpochSeconds
    17  func (t *EpochSeconds) UnmarshalJSON(s []byte) error {
    18  	return (*serialization.EpochTime)(t).UnmarshalJSON(s)
    19  }
    20  
    21  // String returns the time formatted using the format string
    22  func (t EpochSeconds) String() string {
    23  	return serialization.EpochTime(t).String()
    24  }
    25  
    26  // MarshalJSON wrapper for EpochMilliseconds
    27  func (t EpochMilliseconds) MarshalJSON() ([]byte, error) {
    28  	return serialization.EpochTime(t).MarshalJSON()
    29  }
    30  
    31  // UnmarshalJSON wrapper for EpochMilliseconds
    32  func (t *EpochMilliseconds) UnmarshalJSON(s []byte) error {
    33  	return (*serialization.EpochTime)(t).UnmarshalJSON(s)
    34  }
    35  
    36  // String returns the time formatted using the format string
    37  func (t EpochMilliseconds) String() string {
    38  	return serialization.EpochTime(t).String()
    39  }
    40  
    41  func (t *Seconds) UnmarshalJSON(s []byte) error {
    42  	*t = Seconds(string(s))
    43  
    44  	return nil
    45  }