v0.0.22
This commit is contained in:
parent
9d9a6f1c6e
commit
deab986caf
@ -2,59 +2,36 @@ package timeext
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FromSeconds(v int) time.Duration {
|
func FromNanoseconds[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v) * int64(time.Second))
|
return time.Duration(int64(float64(v) * float64(time.Nanosecond)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSecondsInt32(v int32) time.Duration {
|
func FromMicroseconds[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v) * int64(time.Second))
|
return time.Duration(int64(float64(v) * float64(time.Microsecond)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSecondsInt64(v int64) time.Duration {
|
func FromMilliseconds[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(v * int64(time.Second))
|
return time.Duration(int64(float64(v) * float64(time.Millisecond)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSecondsFloat32(v float32) time.Duration {
|
func FromSeconds[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v * float32(time.Second)))
|
return time.Duration(int64(float64(v) * float64(time.Second)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSecondsFloat64(v float64) time.Duration {
|
func FromMinutes[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v * float64(time.Second)))
|
return time.Duration(int64(float64(v) * float64(time.Minute)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromSecondsFloat(v float64) time.Duration {
|
func FromHours[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v * float64(time.Second)))
|
return time.Duration(int64(float64(v) * float64(time.Hour)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromMinutes(v int) time.Duration {
|
func FromDays[T langext.NumberConstraint](v T) time.Duration {
|
||||||
return time.Duration(int64(v) * int64(time.Minute))
|
return time.Duration(int64(float64(v) * float64(24) * float64(time.Hour)))
|
||||||
}
|
|
||||||
|
|
||||||
func FromMinutesFloat(v float64) time.Duration {
|
|
||||||
return time.Duration(int64(v * float64(time.Minute)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func FromMinutesFloat64(v float64) time.Duration {
|
|
||||||
return time.Duration(int64(v * float64(time.Minute)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func FromHoursFloat64(v float64) time.Duration {
|
|
||||||
return time.Duration(int64(v * float64(time.Hour)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func FromDays(v int) time.Duration {
|
|
||||||
return time.Duration(int64(v) * int64(24) * int64(time.Hour))
|
|
||||||
}
|
|
||||||
|
|
||||||
func FromMilliseconds(v int) time.Duration {
|
|
||||||
return time.Duration(int64(v) * int64(time.Millisecond))
|
|
||||||
}
|
|
||||||
|
|
||||||
func FromMillisecondsFloat(v float64) time.Duration {
|
|
||||||
return time.Duration(int64(v * float64(time.Millisecond)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormatNaturalDurationEnglish(iv time.Duration) string {
|
func FormatNaturalDurationEnglish(iv time.Duration) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user