UTC will actually be set new when nothing is inserted moved initUpdate() to the top of main and finish as first order of operations
29 lines
438 B
Go
29 lines
438 B
Go
package Untis
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
var Location *time.Location
|
|
|
|
func init() {
|
|
godotenv.Load("../.env")
|
|
timezone := os.Getenv("LOCATION_ENV")
|
|
if timezone == "" {
|
|
timezone = "UTC"
|
|
}
|
|
loc, err := time.LoadLocation(timezone)
|
|
if err != nil {
|
|
log.Printf("Failed to load timezone, set as UTC")
|
|
loc = time.UTC
|
|
}
|
|
Location = loc
|
|
}
|
|
|
|
func GetTime() time.Time {
|
|
return time.Now().In(Location)
|
|
}
|