This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ntp.go
58 lines (50 loc) · 1.46 KB
/
ntp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package libwimark
import (
"time"
)
type NTPServers []NTPServer
type NTPServer struct {
ID string `json:"id" bson:"_id"`
Title string `json:"title" bson:"title"`
Address string `json:"address" bson:"address"`
Port string `json:"port" bson:"port"`
Status NTPServerStatus `json:"status" bson:"status"`
Priority string `json:"priority" bson:"priority"`
Prefer bool `json:"prefer" bson:"prefer"`
LastSync time.Time `json:"last_sync,omitempty" bson:"last_sync"`
}
type NtpTimeZone struct {
ID string `json:"id" bson:"_id"`
Zone string `json:"time_zone" bson:"time_zone"`
Offset NtpTimeZoneOffset `json:"offset" bson:"offset"`
LastUpdated time.Time `json:"last_updated" bson:"last_updated"`
}
type NtpTimeZoneOffset struct {
Hour int `json:"hour" bson:"hour"`
Min int `json:"min" bson:"min"`
}
type NtpServerDeps struct {
Title string
Host string
Port string
Priority string
Prefer bool
}
func NewNtpServer(deps NtpServerDeps) *NTPServer {
return &NTPServer{
ID: NewUUID(),
Title: deps.Title,
Address: deps.Host,
Port: deps.Port,
Priority: deps.Priority,
Prefer: deps.Prefer,
}
}
func NewNtpTimeZone(zone string, hour, min int) *NtpTimeZone {
return &NtpTimeZone{
ID: NewUUID(),
Zone: zone,
Offset: NtpTimeZoneOffset{Hour: hour, Min: min},
LastUpdated: time.Now(),
}
}