duration

package
v1.6.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Day   = 24 * time.Hour
	Week  = 7 * Day
	Month = 30 * Day
	Year  = 365 * Day
)

Some more common durations extending the constants of default time package. To count the number of units in a Duration, divide:

second := time.Second
fmt.Print(int64(second/time.Millisecond)) // prints 1000

To convert an integer number of units to a Duration, multiply:

seconds := 10
fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

Variables

This section is empty.

Functions

func InvalidTestDuration

func InvalidTestDuration() errors.HandlerError

InvalidTestDuration returns an ErrorMessage describing that the test duration is invalid

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is an extended version of time.Duration. Provides some more functions for formatting and supports units greater than hours.

func GetDuration

func GetDuration(hours, mins int) (Duration, error)

GetDuration gets the test case duration as Duration Returns -1 if the time is invalid

func NewDuration

func NewDuration(hours, minutes, seconds int) Duration

NewDuration is a constructor for Duration. You don't have to calculate the correct nanosecond-float-value of the Duration at your own, but simply insert it into this constructor.

func (Duration) Add

func (d Duration) Add(s Duration) Duration

Add sums up two Durations and return the result. Nothing will be changed at the summands

func (Duration) ConvertToHHMMSS

func (d Duration) ConvertToHHMMSS() (hours, minutes, seconds int)

ConvertToHHMMSS converts the Duration to hours, minutes and seconds. Precision is cut to seconds. Seconds are less 60, 60 seconds are one minutes Minutes are less 60, 60 minutes are one hour hours can be more than 24, when duration is longer than one day

func (Duration) Days

func (d Duration) Days() float64

Days returns the duration as a floating point number of days.

func (Duration) GetDayInMonth

func (d Duration) GetDayInMonth() int

GetDayInMonth returns the days of the partial month. This is not the whole duration in days!

func (Duration) GetDayInWeek

func (d Duration) GetDayInWeek() int

GetDayInWeek returns the days of the partial week. This is not the whole duration in days!

func (Duration) GetDayInYear

func (d Duration) GetDayInYear() int

GetDayInYear returns the days of the partial year. This is not the whole duration in days!

func (Duration) GetHourInDay

func (d Duration) GetHourInDay() int

GetHourInDay returns the hours of the partial day. This is not the whole duration in hours!

func (Duration) GetMinuteInHour

func (d Duration) GetMinuteInHour() int

GetMinuteInHour returns the minutes of the partial hour. This is not the whole duration in minutes!

func (Duration) GetMonthInYear

func (d Duration) GetMonthInYear() int

GetMonthInYear returns the months of the partial year. This is not the whole duration in months!

func (Duration) GetSecondInMinute

func (d Duration) GetSecondInMinute() int

GetSecondInMinute returns the seconds of the partial minute. This is not the whole duration in seconds!

func (Duration) GetWeekInYear

func (d Duration) GetWeekInYear() int

GetWeekInYear returns the weeks of the partial year. This is not the whole duration in weeks!

func (Duration) Months

func (d Duration) Months() float64

Months returns the duration as a floating point number of months.

func (Duration) Sub

func (d Duration) Sub(s Duration) Duration

Sub subtracts the duration given as parameter from the duration on which function is called and return the result. Nothing will be changed at the given variables

func (*Duration) UnmarshalJSON added in v1.5.0

func (dur *Duration) UnmarshalJSON(b []byte) error

func (Duration) Weeks

func (d Duration) Weeks() float64

Weeks returns the duration as a floating point number of weeks.

func (Duration) Years

func (d Duration) Years() float64

Years returns the duration as a floating point number of years.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL