From e16f1c1cd46595710d0f83d3b61e71067009f222 Mon Sep 17 00:00:00 2001 From: Deon Thomas Date: Tue, 10 May 2022 14:16:03 -0400 Subject: [PATCH] Added NowFromTZEnv() to get time via timezone --- utils.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils.go b/utils.go index 3dace875..bd53c805 100644 --- a/utils.go +++ b/utils.go @@ -13,8 +13,10 @@ import ( "fmt" "net" "strings" + "time" "github.com/rs/zerolog/log" + "github.com/spf13/viper" "inet.af/netaddr" "tailscale.com/tailcfg" "tailscale.com/types/key" @@ -327,3 +329,9 @@ func IsStringInSlice(slice []string, str string) bool { return false } + +func NowFromTZEnv() time.Time { + location, _ := time.LoadLocation(viper.GetString("TZ")) + now := time.Now().In(location) + return now +}