github.com/sagernet/sing@v0.4.0-beta.19.0.20240518125136-f67a0988a636/common/ntp/context.go (about) 1 package ntp 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/sagernet/sing/service" 8 ) 9 10 func TimeFuncFromContext(ctx context.Context) func() time.Time { 11 timeService := service.FromContext[TimeService](ctx) 12 if timeService == nil { 13 return nil 14 } 15 return timeService.TimeFunc() 16 }