ntp: Add write_to_system service option

This commit is contained in:
世界
2023-03-18 23:01:10 +08:00
parent 99b2ab5526
commit 0558b3fc5c
10 changed files with 166 additions and 38 deletions

View File

@@ -0,0 +1,14 @@
//go:build linux || darwin
package settings
import (
"time"
"golang.org/x/sys/unix"
)
func SetSystemTime(nowTime time.Time) error {
timeVal := unix.NsecToTimeval(nowTime.UnixNano())
return unix.Settimeofday(&timeVal)
}