Documentation ¶
Index ¶
- func CreateParentDirs(file string) error
- func FmtDuration(dur time.Duration) string
- func ParseDuration(durationStr string) (time.Duration, error)
- func SecsToCompact(t uint32) string
- func SecsToTime(t uint32) time.Time
- func TimeToCompact(t time.Time) string
- func TimeToSecs(t time.Time) uint32
- func TimeToString(t time.Time) string
- type DurWrap
- type FileMode
- type UnixTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateParentDirs ¶
CreateParentDir creates the necessary parent directories for file.
func FmtDuration ¶
func ParseDuration ¶
ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.
It is similar to time.ParseDuration, but differs in the following ways: - It adds support for the following units: "y", "w", "d" - It requires a unit suffix - It does not support mixed unit durations (e.g. `1h10m10s` is not supported). - It does not support negative durations.
func SecsToCompact ¶
SecsToCompact creates a compact string representation from the seconds.
func TimeToCompact ¶
TimeToCompact formats the time as a compat string, e.g. it discards the milliseconds parts if the time only has second resolution.
func TimeToString ¶
TimeToString formats the time as a string.
Types ¶
type DurWrap ¶
DurWrap is a wrapper to enable marshalling and unmarshalling of durations with the custom format.
func (DurWrap) MarshalText ¶
func (*DurWrap) UnmarshalText ¶
type FileMode ¶
func (*FileMode) UnmarshalText ¶
type UnixTime ¶
UnixTime allows parsing and packing timestamps in seconds since epoch.
func (UnixTime) MarshalJSON ¶
MarshalJSON marshals the time as seconds since unix epoch. This must be a value receiver.