Improve ONVIF server

This commit is contained in:
Alex X
2024-12-30 22:34:08 +03:00
parent 2c3219ffcb
commit f601c47218
8 changed files with 506 additions and 346 deletions

View File

@@ -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)
}