mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-15 12:50:52 +08:00
Improve ONVIF server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package onvif
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -106,3 +107,25 @@ func atoi(s string) int {
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func GetPosixTZ(current time.Time) string {
|
||||
// Thanks to https://github.com/Path-Variable/go-posix-time
|
||||
_, offset := current.Zone()
|
||||
|
||||
if current.IsDST() {
|
||||
_, end := current.ZoneBounds()
|
||||
endPlus1 := end.Add(time.Hour * 25)
|
||||
_, offset = endPlus1.Zone()
|
||||
}
|
||||
|
||||
var prefix string
|
||||
if offset < 0 {
|
||||
prefix = "GMT+"
|
||||
offset = -offset / 60
|
||||
} else {
|
||||
prefix = "GMT-"
|
||||
offset = offset / 60
|
||||
}
|
||||
|
||||
return prefix + fmt.Sprintf("%02d:%02d", offset/60, offset%60)
|
||||
}
|
||||
|
Reference in New Issue
Block a user