itd/api/time.go

34 lines
643 B
Go
Raw Normal View History

package api
import (
"time"
"go.arsenm.dev/itd/internal/types"
)
2021-10-23 04:01:18 +00:00
// SetTime sets the given time on the connected device
func (c *Client) SetTime(t time.Time) error {
_, err := c.request(types.Request{
Type: types.ReqTypeSetTime,
Data: t.Format(time.RFC3339),
})
if err != nil {
return err
}
return nil
}
2021-10-23 04:01:18 +00:00
// SetTimeNow sets the time on the connected device to
// the current time. This is more accurate than
// SetTime(time.Now()) due to RFC3339 formatting
func (c *Client) SetTimeNow() error {
_, err := c.request(types.Request{
Type: types.ReqTypeSetTime,
Data: "now",
})
if err != nil {
return err
}
return nil
}