 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- type Day
- func (d Day) After(other Day) bool
- func (d Day) Before(other Day) bool
- func (d Day) Compare(other Day) int
- func (d Day) Equal(other Day) bool
- func (d Day) Format(layout string) string
- func (d Day) In(loc *time.Location) Day
- func (d Day) IsZero() bool
- func (d Day) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (d Day) MarshalJSON() ([]byte, error)
- func (d Day) String() string
- func (d Day) ToAttributeValueMap(key string) map[string]types.AttributeValue
- func (d Day) ToTime() time.Time
- func (d *Day) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
- func (d *Day) UnmarshalJSON(data []byte) error
 
- type EpochMillisecond
- func (e EpochMillisecond) After(other EpochMillisecond) bool
- func (e EpochMillisecond) Before(other EpochMillisecond) bool
- func (e EpochMillisecond) Compare(other EpochMillisecond) int
- func (e EpochMillisecond) Equal(other EpochMillisecond) bool
- func (e EpochMillisecond) Format(layout string) string
- func (e EpochMillisecond) IsZero() bool
- func (e EpochMillisecond) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (e EpochMillisecond) MarshalJSON() ([]byte, error)
- func (e EpochMillisecond) String() string
- func (e EpochMillisecond) ToAttributeValueMap(key string) map[string]types.AttributeValue
- func (e *EpochMillisecond) ToTime() time.Time
- func (e *EpochMillisecond) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
- func (e *EpochMillisecond) UnmarshalJSON(data []byte) error
 
- type EpochSecond
- func (e EpochSecond) After(other EpochSecond) bool
- func (e EpochSecond) Before(other EpochSecond) bool
- func (e EpochSecond) Compare(other EpochSecond) int
- func (e EpochSecond) Equal(other EpochSecond) bool
- func (e EpochSecond) Format(layout string) string
- func (e EpochSecond) IsZero() bool
- func (e EpochSecond) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (e EpochSecond) MarshalJSON() ([]byte, error)
- func (e EpochSecond) String() string
- func (e EpochSecond) ToAttributeValueMap(key string) map[string]types.AttributeValue
- func (e *EpochSecond) ToTime() time.Time
- func (e *EpochSecond) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
- func (e *EpochSecond) UnmarshalJSON(data []byte) error
 
- type Timestamp
- func (t Timestamp) After(other Timestamp) bool
- func (t Timestamp) Before(other Timestamp) bool
- func (t Timestamp) Compare(other Timestamp) int
- func (t Timestamp) Equal(other Timestamp) bool
- func (t Timestamp) Format(layout string) string
- func (t Timestamp) IsZero() bool
- func (t Timestamp) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) String() string
- func (t Timestamp) ToAttributeValueMap(key string) map[string]types.AttributeValue
- func (t *Timestamp) ToTime() time.Time
- func (t *Timestamp) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
- func (t *Timestamp) UnmarshalJSON(data []byte) error
 
Constants ¶
const DayLayout = "2006-01-02"
    DayLayout is the string layout as well as DynamoDB string value of Day.
const FractionalSecondLayout = "2006-01-02T15:04:05.000Z"
    FractionalSecondLayout is the string layout as well as DynamoDB string value of Timestamp.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Day ¶
type Day struct {
	// contains filtered or unexported fields
}
    Day is a timestamp that is truncated to start of day.
Day is a struct to avoid the truncation pitfalls that other timestamps have.
func ParseDay ¶
ParseDay creates an instance of Day from parsing the specified string.
If the string fails to be parsed using layout DayLayout, a zero-value Day is returned.
func TodayInLocation ¶
TodayInLocation creates a new Day with the specified location.
func TruncateToStartOfDay ¶
TruncateToStartOfDay creates a new Day from the specified time.Time.
func (Day) After ¶
After is convenient method to time.Time.After.
func (Day) Before ¶
Before is convenient method to time.Time.Before.
func (Day) Compare ¶
Compare is convenient method to time.Time.Compare.
func (Day) Equal ¶
Equal is convenient method to time.Time.Equal.
func (Day) Format ¶
Format is convenient method to time.Time.Format.
func (Day) MarshalDynamoDBAttributeValue ¶
func (d Day) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue must not use receiver pointer to allow both pointer and non-pointer usage.
func (Day) MarshalJSON ¶
MarshalJSON must not use receiver pointer to allow both pointer and non-pointer usage.
func (Day) ToAttributeValueMap ¶
func (d Day) ToAttributeValueMap(key string) map[string]types.AttributeValue
ToAttributeValueMap is convenient method to implement [.model.HasCreatedDay] or [.model.HasModifiedDay].
func (*Day) UnmarshalDynamoDBAttributeValue ¶
func (d *Day) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
func (*Day) UnmarshalJSON ¶
type EpochMillisecond ¶
EpochMillisecond is epoch millisecond in UTC, formatted and marshalled as a positive integer (e.g. 1136214245000).
Because EpochMillisecond wraps around time.Time and truncates its serialisation, deserialisation of EpochMillisecond values will not result in identical time.Time values. For example:
func TestEpochMillisecond_TruncateNanosecond(t *testing.T) {
	v, err := time.Parse(time.RFC3339Nano, "2006-01-02T15:04:05.999999Z")
	if err != nil {
		t.Error(err)
	}
	data, err := json.Marshal(EpochMillisecond(v))
	if err != nil {
		t.Error(err)
	}
	got := EpochMillisecond(time.Time{})
	if err := json.Unmarshal(data, &got); err != nil {
		t.Error(err)
	}
	// got's underlying time.time is truncated to 2006-01-02T15:04:05.
	if reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("shouldn't be equal; got %v, want %v", got, v)
	}
	// if we reset v's nano time, then they are equal.
	v = time.Date(v.Year(), v.Month(), v.Day(), v.Hour(), v.Minute(), v.Second(), got.ToTime().Nanosecond(), v.Location())
	if !reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("got %#v, want %#v", got.ToTime(), v)
	}
}
func (EpochMillisecond) After ¶
func (e EpochMillisecond) After(other EpochMillisecond) bool
After is convenient method to time.Time.After.
func (EpochMillisecond) Before ¶
func (e EpochMillisecond) Before(other EpochMillisecond) bool
Before is convenient method to time.Time.Before.
func (EpochMillisecond) Compare ¶
func (e EpochMillisecond) Compare(other EpochMillisecond) int
Compare is convenient method to time.Time.Compare.
func (EpochMillisecond) Equal ¶
func (e EpochMillisecond) Equal(other EpochMillisecond) bool
Equal is convenient method to time.Time.Equal.
func (EpochMillisecond) Format ¶
func (e EpochMillisecond) Format(layout string) string
Format is convenient method to time.Time.Format.
func (EpochMillisecond) IsZero ¶
func (e EpochMillisecond) IsZero() bool
IsZero is convenient method to time.Time.IsZero.
func (EpochMillisecond) MarshalDynamoDBAttributeValue ¶
func (e EpochMillisecond) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue must not use receiver pointer to allow both pointer and non-pointer usage.
func (EpochMillisecond) MarshalJSON ¶
func (e EpochMillisecond) MarshalJSON() ([]byte, error)
MarshalJSON must not use receiver pointer to allow both pointer and non-pointer usage.
func (EpochMillisecond) String ¶
func (e EpochMillisecond) String() string
String implements the fmt.Stringer interface.
func (EpochMillisecond) ToAttributeValueMap ¶
func (e EpochMillisecond) ToAttributeValueMap(key string) map[string]types.AttributeValue
ToAttributeValueMap is convenient method to implement [.model.HasCreatedTimestamp] or [.model.HasModifiedTimestamp].
func (*EpochMillisecond) ToTime ¶
func (e *EpochMillisecond) ToTime() time.Time
ToTime returns the underlying time.Time instance.
func (*EpochMillisecond) UnmarshalDynamoDBAttributeValue ¶
func (e *EpochMillisecond) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
func (*EpochMillisecond) UnmarshalJSON ¶
func (e *EpochMillisecond) UnmarshalJSON(data []byte) error
type EpochSecond ¶
EpochSecond is epoch second in UTC, formatted and marshalled as a positive integer (e.g. 1136214245).
This can be used as DynamoDB's time-to-live value (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html).
Because EpochSecond wraps around time.Time and truncates its serialisation, deserialisation of EpochSecond values will not result in identical time.Time values. For example:
func TestEpochSecond_TruncateNanosecond(t *testing.T) {
	v, err := time.Parse(time.RFC3339Nano, "2006-01-02T15:04:05.999999Z")
	if err != nil {
		t.Error(err)
	}
	data, err := json.Marshal(EpochSecond(v))
	if err != nil {
		t.Error(err)
	}
	got := EpochSecond(time.Time{})
	if err := json.Unmarshal(data, &got); err != nil {
		t.Error(err)
	}
	// got's underlying time.time is truncated to 2006-01-02T15:04:05.
	if reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("shouldn't be equal; got %v, want %v", got, v)
	}
	// if we reset v's nano time, then they are equal.
	v = time.Date(v.Year(), v.Month(), v.Day(), v.Hour(), v.Minute(), v.Second(), got.ToTime().Nanosecond(), v.Location())
	if !reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("got %#v, want %#v", got.ToTime(), v)
	}
}
func (EpochSecond) After ¶
func (e EpochSecond) After(other EpochSecond) bool
After is convenient method to time.Time.After.
func (EpochSecond) Before ¶
func (e EpochSecond) Before(other EpochSecond) bool
Before is convenient method to time.Time.Before.
func (EpochSecond) Compare ¶
func (e EpochSecond) Compare(other EpochSecond) int
Compare is convenient method to time.Time.Compare.
func (EpochSecond) Equal ¶
func (e EpochSecond) Equal(other EpochSecond) bool
Equal is convenient method to time.Time.Equal.
func (EpochSecond) Format ¶
func (e EpochSecond) Format(layout string) string
Format is convenient method to time.Time.Format.
func (EpochSecond) IsZero ¶
func (e EpochSecond) IsZero() bool
IsZero is convenient method to time.Time.IsZero.
func (EpochSecond) MarshalDynamoDBAttributeValue ¶
func (e EpochSecond) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue must not use receiver pointer to allow both pointer and non-pointer usage.
func (EpochSecond) MarshalJSON ¶
func (e EpochSecond) MarshalJSON() ([]byte, error)
MarshalJSON must not use receiver pointer to allow both pointer and non-pointer usage.
func (EpochSecond) String ¶
func (e EpochSecond) String() string
String implements the fmt.Stringer interface.
func (EpochSecond) ToAttributeValueMap ¶
func (e EpochSecond) ToAttributeValueMap(key string) map[string]types.AttributeValue
ToAttributeValueMap is convenient method to implement [.model.HasCreatedTimestamp] or [.model.HasModifiedTimestamp].
func (*EpochSecond) ToTime ¶
func (e *EpochSecond) ToTime() time.Time
ToTime returns the underlying time.Time instance.
func (*EpochSecond) UnmarshalDynamoDBAttributeValue ¶
func (e *EpochSecond) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error
func (*EpochSecond) UnmarshalJSON ¶
func (e *EpochSecond) UnmarshalJSON(data []byte) error
type Timestamp ¶
Timestamp is a UTC timestamp formatted and marshalled as a string using FractionalSecondLayout ("2006-01-02T15:04:05.000Z") layout.
Because Timestamp wraps around time.Time and truncates its serialisation, deserialisation of Timestamp values will not result in identical time.Time values. For example:
func TestTimestamp_TruncateNanosecond(t *testing.T) {
	v, err := time.Parse(time.RFC3339Nano, "2006-01-02T15:04:05.999999Z")
	if err != nil {
		t.Error(err)
	}
	data, err := json.Marshal(Timestamp(v))
	if err != nil {
		t.Error(err)
	}
	got := Timestamp(time.Time{})
	if err := json.Unmarshal(data, &got); err != nil {
		t.Error(err)
	}
	// got's underlying time.time is truncated to 2006-01-02T15:04:05.999.
	if reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("shouldn't be equal; got %v, want %v", got, v)
	}
	// if we reset v's nano time, then they are equal.
	v = time.Date(v.Year(), v.Month(), v.Day(), v.Hour(), v.Minute(), v.Second(), got.ToTime().Nanosecond(), v.Location())
	if !reflect.DeepEqual(got.ToTime(), v) {
		t.Errorf("got %#v, want %#v", got.ToTime(), v)
	}
}
func ParseTimestamp ¶
ParseTimestamp creates an instance of Timestamp from parsing the specified string.
If the string fails to be parsed using layout FractionalSecondLayout, a zero-value Timestamp is returned.
func (Timestamp) After ¶
After is convenient method to time.Time.After.
func (Timestamp) Before ¶
Before is convenient method to time.Time.Before.
func (Timestamp) Compare ¶
Compare is convenient method to time.Time.Compare.
func (Timestamp) Equal ¶
Equal is convenient method to time.Time.Equal.
func (Timestamp) Format ¶
Format is convenient method to time.Time.Format.
func (Timestamp) IsZero ¶
IsZero is convenient method to time.Time.IsZero.
func (Timestamp) MarshalDynamoDBAttributeValue ¶
func (t Timestamp) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)
MarshalDynamoDBAttributeValue must not use receiver pointer to allow both pointer and non-pointer usage.
func (Timestamp) MarshalJSON ¶
MarshalJSON must not use receiver pointer to allow both pointer and non-pointer usage.
func (Timestamp) ToAttributeValueMap ¶
func (t Timestamp) ToAttributeValueMap(key string) map[string]types.AttributeValue
ToAttributeValueMap is convenient method to implement [.model.HasCreatedTimestamp] or [.model.HasModifiedTimestamp].
func (*Timestamp) UnmarshalDynamoDBAttributeValue ¶
func (t *Timestamp) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error