Documentation
¶
Index ¶
- Constants
- func DurationDays(d time.Duration) float64
- func DurationDaysInt64(dur time.Duration) int64
- func DurationStringMinutesSeconds(durationSeconds int64) (string, error)
- func DurationStringUnit(d, unit time.Duration, prec int, addSuffix bool) string
- func DurationUnitSuffix(unit time.Duration) string
- func DurationWeeks(d time.Duration) float64
- func DurationYears(d time.Duration) float64
- func FormatDurationInfoMinSec(di DurationInfo) string
- func MaxDuration(durs []time.Duration) time.Duration
- func MustParseDuration(s string) time.Duration
- func NewDuration(day, hour, min, sec, nsec int) time.Duration
- func NewDurationFloat(day, hour, min, sec float64, nsec int64) time.Duration
- func NewDurationStrings(hour, min, sec string) (time.Duration, error)
- func NowDeltaDuration(d time.Duration) time.Time
- func NowDeltaParseDuration(s string) (time.Time, error)
- func ParseDuration(s string) (time.Duration, error)
- func SubDuration(dur1, dur2 time.Duration) time.Duration
- func SumDurations(durations ...time.Duration) time.Duration
- type DurationInfo
- type DurationInfoString
- type Durations
- type Spec
- type Unit
Constants ¶
const ( UnitYear Unit = "year" UnitMonth Unit = "month" UnitWeek Unit = "week" UnitDay Unit = "day" UnitHour Unit = "hour" UnitMinute Unit = "minute" UnitSecond Unit = "second" UnitMillisecond Unit = "millisecond" UnitMicrosecond Unit = "microsecond" UnitNanosecond Unit = "nanosecond" UnitYearPlural = "years" UnitMonthPlural = "months" UnitWeekPlural = "weeks" UnitDayPlural = "days" UnitHourPlural = "hours" UnitMinutePlural = "minutes" UnitSecondPlural = "seconds" UnitMillisecondPlural = "milliseconds" UnitMicrosecondPlural = "microseconds" UnitNanosecondPlural = "nanoseconds" UnitBusinessDay = "businessday" UnitSuffixNanosecond = "ns" UnitSuffixMicrosecond = "us" UnitSuffixMillisecond = "ms" UnitSuffixSecond = "s" UnitSuffixMinute = "m" UnitSuffixHour = "h" UnitSuffixDay = "d" UnitSuffixWeek = "w" Day = 24 * time.Hour Week = 7 * Day Year = 365 * Day Decade = 10 * Year Score = 2 * Decade Century = 10 * Decade WorkDay = 8 * time.Hour WorkWeek = 5 * WorkDay WorkDay996 = 12 * time.Hour WorkWeek996 = 6 * WorkDay996 HoursPerDay = float32(24) DaysPerWeek = float32(7) DaySeconds = 24 * 60 * 60 WeekSeconds = 7 * DaySeconds YearSeconds = (365 * DaySeconds) + (6 * 60 * 60) )
Variables ¶
This section is empty.
Functions ¶
func DurationDays ¶
func DurationDaysInt64 ¶
func DurationStringUnit ¶
DurationStringUnit converts a Duration to a string with a fixed time unit. If an invalid `unit`, is provided, the function will return the output of `time.Duration.String()`.
func DurationUnitSuffix ¶
func DurationWeeks ¶
func DurationYears ¶
func FormatDurationInfoMinSec ¶
func FormatDurationInfoMinSec(di DurationInfo) string
FormatDurationInfoMinSec returns the duration as a simple string like 01:01.
func MustParseDuration ¶
func NewDuration ¶
func NewDurationFloat ¶
func ParseDuration ¶
ParseDuration adds days (d), weeks (w), years (y).
func SubDuration ¶
SubDuration subtracts one duration from another and returns the result as a `time.Duration`.
Types ¶
type DurationInfo ¶
type DurationInfo struct {
DaysPerWeek float32
HoursPerDay float32
Weeks int64
Days int64
Hours int64
Minutes int64
Seconds int64
Milliseconds int64
Microseconds int64
Nanoseconds int64
}
DurationInfo is a struct that holds integer values for each time unit including hours, minutes, seconds milliseconds, microseconds, and nanoseconds.
func NewDurationInfo ¶
func NewDurationInfo(d time.Duration, daysPerWeek, hoursPerDay float32) DurationInfo
NewDurationInfo returns a DurationInfo struct for a duration in nanos. If 'daysPerWeek` or `hoursPerDay` are set to zero, the default values of 7 and 24 are used.
func ParseDurationInfo ¶
func ParseDurationInfo(s string) (DurationInfo, error)
ParseDurationInfo converts a Jira human readable string into a `DurationInfo` struct.
func (DurationInfo) Duration ¶
func (di DurationInfo) Duration(hoursPerDay, daysPerWeek float32) time.Duration
Duration returns a `time.Duration` struct. Params for `hoursPerDay` and `daysPerWeek` are used for atlernate values such as working hours per day and working days per week, e.g. 8 hours per day and 5 days per week.
type DurationInfoString ¶
type DurationInfoString struct {
DaysPerWeek float32
HoursPerDay float32
Weeks string
Days string
Hours string
Minutes string
Seconds string
Milliseconds string
Microseconds string
Nanoseconds string
}
DurationInfoString represets a set of time duration data. It is useful for converting parsed time data into a `time.Duration` struct. `DaysPerWeek` and `HoursPerDay` are provided as overrides to standard value of 7 and 24 in the case of business context, e.g. 5 days per week and 8 hours per day.