Documentation
¶
Overview ¶
Package temporal provides value objects related to temporal information.
Package temporal provides value objects related to time and duration. It includes implementations for time-based value objects that follow the domain-driven design principles.
Package temporal provides value objects related to time and versioning information.
Index ¶
- type Duration
- func (v Duration) Add(other Duration) (Duration, error)
- func (v Duration) Equals(other Duration) bool
- func (v Duration) Format(format string) string
- func (v Duration) Hours() float64
- func (v Duration) IsEmpty() bool
- func (v Duration) MarshalJSON() ([]byte, error)
- func (v Duration) Milliseconds() int64
- func (v Duration) Minutes() float64
- func (v Duration) Seconds() float64
- func (v Duration) String() string
- func (v Duration) Subtract(other Duration) (Duration, error)
- func (v Duration) ToMap() map[string]interface{}
- func (v Duration) Validate() error
- func (v Duration) Value() time.Duration
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(other Time) bool
- func (t Time) Before(other Time) bool
- func (t Time) Equal(other Time) bool
- func (t Time) Equals(other Time) bool
- func (t Time) IsEmpty() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) String() string
- func (t Time) Sub(other Time) time.Duration
- func (t Time) ToMap() map[string]interface{}
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Validate() error
- func (t Time) Value() time.Time
- type Version
- func (v Version) Build() string
- func (v Version) CompareTo(other Version) int
- func (v Version) Equals(other Version) bool
- func (v Version) IsEmpty() bool
- func (v Version) IsPreRelease() bool
- func (v Version) Major() int
- func (v Version) Minor() int
- func (v Version) NextMajor() Version
- func (v Version) NextMinor() Version
- func (v Version) NextPatch() Version
- func (v Version) Patch() int
- func (v Version) PreRelease() string
- func (v Version) String() string
- func (v Version) ToMap() map[string]interface{}
- func (v Version) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration struct {
base.BaseStructValueObject
// contains filtered or unexported fields
}
Duration represents a time duration value object
func NewDuration ¶
NewDuration creates a new Duration with validation
func ParseDuration ¶
ParseDuration creates a new Duration from a string
func (Duration) Format ¶
Format returns a formatted string representation of the duration Format options: - "short": "1h 30m 45s" - "long": "1 hour 30 minutes 45 seconds" - "compact": "1:30:45"
func (Duration) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (Duration) Milliseconds ¶
Milliseconds returns the duration as an integer number of milliseconds
func (Duration) Subtract ¶
Subtract subtracts another Duration and returns a new Duration If the result would be negative, it returns zero duration
type Time ¶
type Time struct {
base.BaseStructValueObject
// contains filtered or unexported fields
}
Time represents a time value object based on RFC 3339 format. It encapsulates a time.Time value and provides methods for comparison, arithmetic, and conversion operations.
func NewTime ¶
NewTime creates a new Time with validation. It returns an error if the validation fails.
func NewTimeFromString ¶
NewTimeFromString creates a new Time from an RFC 3339 formatted string. It returns an error if the string is empty or not in valid RFC 3339 format.
func (Time) Add ¶
Add returns a new Time with the given duration added. It properly handles any errors from the NewTime constructor.
func (Time) Equal ¶
Equal is maintained for backward compatibility. New code should use Equals() instead.
func (Time) Equals ¶
Equals checks if two times are equal. This method follows the naming convention used in other value objects.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface. It marshals the time as an RFC 3339 formatted string.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface. It unmarshals an RFC 3339 formatted string into a Time.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a semantic version (major.minor.patch)
func NewVersion ¶
NewVersion creates a new Version with validation
func ParseVersion ¶
ParseVersion creates a new Version from a string in format "major.minor.patch[-prerelease][+build]"
func (Version) CompareTo ¶
CompareTo compares this version to another version Returns:
-1 if this version is less than the other 0 if this version is equal to the other 1 if this version is greater than the other
func (Version) IsPreRelease ¶
IsPreRelease checks if this is a pre-release version
func (Version) PreRelease ¶
PreRelease returns the pre-release identifier