|
|
@@ -1,7 +1,11 @@
|
|
|
// package app 应用信息包
|
|
|
package app
|
|
|
|
|
|
-import "github.com/runningwater/gohub/pkg/config"
|
|
|
+import (
|
|
|
+ "time"
|
|
|
+
|
|
|
+ "github.com/runningwater/gohub/pkg/config"
|
|
|
+)
|
|
|
|
|
|
func IsLocal() bool {
|
|
|
// 判断是否是本地环境
|
|
|
@@ -14,3 +18,13 @@ func IsProduction() bool {
|
|
|
func IsTesting() bool {
|
|
|
return config.Get("app.env") == "testing"
|
|
|
}
|
|
|
+
|
|
|
+// TimenowInTimezone 获取当前时间, 支持时区
|
|
|
+func TimenowInTimezone() time.Time {
|
|
|
+ timezone := config.GetString("app.timezone")
|
|
|
+ if timezone == "" {
|
|
|
+ timezone = "Asia/Shanghai"
|
|
|
+ }
|
|
|
+ chinaTimeZone, _ := time.LoadLocation(timezone)
|
|
|
+ return time.Now().In(chinaTimeZone)
|
|
|
+}
|