Documentation ¶
Index ¶
- Constants
- type Duration
- func (d Duration) Add(s Duration) Duration
- func (d Duration) ConvertToHHMMSS() (hours, minutes, seconds int)
- func (d Duration) Days() float64
- func (d Duration) GetDayInMonth() int
- func (d Duration) GetDayInWeek() int
- func (d Duration) GetDayInYear() int
- func (d Duration) GetHourInDay() int
- func (d Duration) GetMinuteInHour() int
- func (d Duration) GetMonthInYear() int
- func (d Duration) GetSecondInMinute() int
- func (d Duration) GetWeekInYear() int
- func (d Duration) Months() float64
- func (d Duration) StringTimeAgo() string
- func (d Duration) Sub(s Duration) Duration
- func (d Duration) Weeks() float64
- func (d Duration) Years() float64
Constants ¶
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 ¶
This section is empty.
Types ¶
type Duration ¶
Duration is an extended version of time.Duration. Provides some more functions for formatting and supports units greater than hours.
func NewDuration ¶
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 ¶
Add sums up two Durations and return the result. Nothing will be changed at the summands
func (Duration) ConvertToHHMMSS ¶
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) GetDayInMonth ¶
GetDayInMonth returns the days of the partial month. This is not the whole duration in days!
func (Duration) GetDayInWeek ¶
GetDayInWeek returns the days of the partial week. This is not the whole duration in days!
func (Duration) GetDayInYear ¶
GetDayInYear returns the days of the partial year. This is not the whole duration in days!
func (Duration) GetHourInDay ¶
GetHourInDay returns the hours of the partial day. This is not the whole duration in hours!
func (Duration) GetMinuteInHour ¶
GetMinuteInHour returns the minutes of the partial hour. This is not the whole duration in minutes!
func (Duration) GetMonthInYear ¶
GetMonthInYear returns the months of the partial year. This is not the whole duration in months!
func (Duration) GetSecondInMinute ¶
GetSecondInMinute returns the seconds of the partial minute. This is not the whole duration in seconds!
func (Duration) GetWeekInYear ¶
GetWeekInYear returns the weeks of the partial year. This is not the whole duration in weeks!
func (Duration) StringTimeAgo ¶
StringTimeAgo gets a duration and returns the time passed since then formatted as string. If the duration is smaller than one minute, return "1 Minute ago". The biggest time format are years
func (Duration) Sub ¶
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