1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package isapi
- import (
- "encoding/xml"
- "net/url"
- )
- // Time
- type Time struct {
- XMLName xml.Name `xml:"Time,omitempty"`
- XMLVersion string `xml:"version,attr"`
- XMLNamespace string `xml:"xmlns,attr"`
- TimeMode string `xml:"timeMode,omitempty" json:"timeMode,omitempty"` //校时方式,[NTP#NTP校时,manual#手动校时,satellite#卫星校时,platform#平台校时,NONE#不允校时或无校时源,GB28181#GB28181校时,PTP#PTP校时]
- LocalTime string `xml:"localTime,omitempty" json:"localTime,omitempty"`
- TimeZone string `xml:"timeZone,omitempty" json:"timeZone,omitempty"` //CST为时区名称,-8:00:00为(UTC时间-本地时间)
- }
- // GetTime 获取时间信息
- func (c *Client) GetTime() (resp *Time, err error) {
- path := "/ISAPI/System/time"
- u, err := url.Parse(c.BaseURL + path)
- if err != nil {
- return nil, err
- }
- body, err := c.Get(u)
- if err != nil {
- return nil, err
- }
- err = xml.Unmarshal(body, &resp)
- if err != nil {
- return nil, err
- }
- return resp, nil
- }
- // PutTime 更新时间
- func (c *Client) PutTime(data []byte) (resp []byte, err error) {
- u, err := url.Parse(c.BaseURL + "/ISAPI/System/time")
- if err != nil {
- return nil, err
- }
- resp, err = c.PutXML(u, data)
- if err != nil {
- return nil, err
- }
- return resp, nil
- }
|