Documentation ¶
Index ¶
Constants ¶
const ( ISO8601Clock = "15:04:05" ISO8601ClockMicro = "15:04:05.000000" )
Templates to parse clocks
Variables ¶
var ( ErrInvalidClock = errors.New("timetype: invalid clock") ErrInvalidDuration = errors.New("timetype: invalid duration") )
Parsing errors
var ErrInvalidWeekday = errors.New("timetype: invalid weekday")
ErrInvalidWeekday if the weekday string cannot be parsed into time.Weekday
Functions ¶
func ParseWeekday ¶ added in v0.1.0
ParseWeekday parses a weekday from a string and, if it's can't be parsed, returns
Types ¶
type Clock ¶
Clock is a wrapper for time.time to allow parsing datetime stamp with time only in ISO 8601 format, like "15:04:05"
func NewClock ¶ added in v0.1.0
NewClock returns the Clock in the given location with given hours, minutes and secs
func NewUTCClock ¶ added in v0.1.0
NewUTCClock returns new clock with given hours, minutes and seconds in the UTC location
func (Clock) GoString ¶ added in v0.1.0
GoString implements fmt.GoStringer to use Clock in %#v formats
func (Clock) MarshalJSON ¶
MarshalJSON marshals time into time
func (Clock) String ¶ added in v0.1.0
String implements fmt.Stringer to print and log Clock properly
func (*Clock) UnmarshalJSON ¶
UnmarshalJSON converts time to ISO 8601 representation
type Duration ¶
Duration is a wrapper of time.Duration, that allows to marshal and unmarshal time in RFC3339 format
func (Duration) MarshalJSON ¶
MarshalJSON simply marshals duration into nanoseconds
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON converts time duration from RFC3339 format into time.Duration
type UnknownFormatError ¶ added in v0.1.2
UnknownFormatError composes all errors got from all attempts to parse in different layouts
func (*UnknownFormatError) Error ¶ added in v0.1.2
func (e *UnknownFormatError) Error() string
Error returns the string representation of a UnknownFormatError.