25 lines
505 B
Go
25 lines
505 B
Go
package utils
|
|
|
|
import (
|
|
"context"
|
|
"github.com/spf13/cast"
|
|
"time"
|
|
)
|
|
|
|
func GetUidUint(ctx context.Context) uint {
|
|
uid, _ := cast.ToStringMapInt(ctx.Value("data"))["id"]
|
|
return uint(uid)
|
|
}
|
|
|
|
func GetUid(ctx context.Context) int {
|
|
uid, _ := cast.ToStringMapInt(ctx.Value("data"))["id"]
|
|
return uid
|
|
}
|
|
|
|
func TodayRemainSeconds() int {
|
|
now := time.Now()
|
|
end, _ := time.ParseInLocation(time.DateOnly, now.Format(time.DateOnly), time.Local)
|
|
end = end.AddDate(0, 0, 1)
|
|
return int(end.Sub(now).Seconds())
|
|
}
|