Time toolkit for golang
go get -u github.com/mef13/timerange
Calculating time range based on current time:
package main
import (
"fmt"
"github.com/mef13/timerange"
)
func main() {
daysInMonth := timerange.Now().InMonth().ToDays()
secondsInQuarter := timerange.Now().InQuarter().ToSeconds()
fmt.Println(daysInMonth)
fmt.Println(secondsInQuarter)
}
Calculating time range based on custom time:
package main
import (
"fmt"
"github.com/mef13/timerange"
"time"
)
func main() {
customTime := time.Date(2020, 2, 3, 2, 1, 10, 9, time.UTC)
secondsInMonth := timerange.FromTime(customTime).InMonth().ToSeconds()
fmt.Println(secondsInMonth)
}
Contributions are always welcome!
This project is under Apache 2.0 License. See the LICENSE file for the full license text.