Documentation ¶
Index ¶
- func Date(t time.Time) string
- func Epoch(d time.Duration) string
- func StartOfDay(t time.Time) time.Time
- func StartOfHour(t time.Time) time.Time
- func UnixNanoString(t time.Time) string
- type Convertible
- func (c Convertible) MarshalCSV() (string, error)
- func (c Convertible) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (c Convertible) MarshalJSON() ([]byte, error)
- func (c Convertible) MarshalYAML() (interface{}, error)
- func (c *Convertible) Scan(value interface{}) error
- func (c *Convertible) UnmarshalCSV(raw string) error
- func (c *Convertible) UnmarshalDynamoDBAttributeValue(value types.AttributeValue) error
- func (c *Convertible) UnmarshalJSON(raw []byte) error
- func (c *Convertible) UnmarshalYAML(value *yaml.Node) error
- func (c Convertible) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartOfDay ¶
StartOfDay trims everything after the day from the provided time
func StartOfHour ¶
StartOfHour trims everything after the hour from the provided time
func UnixNanoString ¶
UnixNanoString creates a string containing the Unix nano timestamp that is valid up to the limit of Unix
Types ¶
type Convertible ¶ added in v1.1.8
Convertible represents a wrapper for a time.Time object, allowing it to be converted to and from various formats, including SQL, DynamoDB, JSON, YAML and CSV. The exact format the time should take will be determined by the value provided to the Layout field and will operate according to Go's documentation for time.Time.
func WithLayout ¶ added in v1.1.8
func WithLayout(inner time.Time, layout string) Convertible
WithLayout creates a new Convertible time from an inner time and a layout.
func (Convertible) MarshalCSV ¶ added in v1.1.8
func (c Convertible) MarshalCSV() (string, error)
MarshalCSV converts the time contained in the Convertible to a CSV column, using the Layout field associated with this Convertible to format the time (or RFC3339 if no layout was provided).
func (Convertible) MarshalDynamoDBAttributeValue ¶ added in v1.1.8
func (c Convertible) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue converts the time contained in the Convertible to a DynamoDB AttributeValue object, using the Layout field associated with this Convertible to format the time (or RFC3339 if no layout was provided). The Convertible converts to a DynamoDB string attribute.
func (Convertible) MarshalJSON ¶ added in v1.1.8
func (c Convertible) MarshalJSON() ([]byte, error)
MarshalJSON converts the time contained in the Convertible to JSON, using the Layout field associated with this Convertible to format the time (or RFC3339 if no layout was provided).
func (Convertible) MarshalYAML ¶ added in v1.1.9
func (c Convertible) MarshalYAML() (interface{}, error)
MarshalYAML converts the time contained in the Convertible to a YAML node, using the Layout field associated with this Convertible to format the time (or RFC3339 if no layout was provided).
func (*Convertible) Scan ¶ added in v1.1.8
func (c *Convertible) Scan(value interface{}) error
Scan converts an SQL driver value to a time.Time and sets the inner Time on this Convertible to that value, using the Layout field to parse the raw data (or RFC3339 if no layout was provided). This function expects the driver value to be convertible to a string.
func (*Convertible) UnmarshalCSV ¶ added in v1.1.8
func (c *Convertible) UnmarshalCSV(raw string) error
UnmarshalCSV converts a CSV column to a time.Time and sets the inner Time on this Convertible to that value, using the Layout field to parse the raw data (or RFC3339 if no layout was provided).
func (*Convertible) UnmarshalDynamoDBAttributeValue ¶ added in v1.1.8
func (c *Convertible) UnmarshalDynamoDBAttributeValue(value types.AttributeValue) error
UnmarshalDynamoDBAttributeValue converts a DynamoDB AttributeValue object to a time.Time and sets the inner Time on this Convertible to that value, using the Layout field to parse the raw data (or RFC3339 if no layout was provided). String or byte array AttributeValues can be converted and NULL AttributeValues will result in no change to the object. Any other type of AttributeValue will result in an error.
func (*Convertible) UnmarshalJSON ¶ added in v1.1.8
func (c *Convertible) UnmarshalJSON(raw []byte) error
UnmarshalJSON converts a JSON string to a time.Time and sets the inner Time on this Convertible to that value, using the Layout field to parse the raw data (or RFC3339 if no layout was provided).
func (*Convertible) UnmarshalYAML ¶ added in v1.1.9
func (c *Convertible) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML converts a YAML node to a time.Time and sets the inner Time on this Convertible to that value, using the Layout field to parse the raw data (or RFC3339 if no layout was provided).