diff options
author | Qais Patankar <qaisjp@gmail.com> | 2020-03-15 22:43:46 +0000 |
---|---|---|
committer | Wim <wim@42.be> | 2020-03-22 00:02:48 +0100 |
commit | 76e5fe5a87d7e60919075f96eee599f3c6255a9f (patch) | |
tree | af3181ad6aadaea02069473a3718a827be888426 /vendor/github.com/rickb777/date/period/marshal.go | |
parent | 802c80f40c709ba4967de317e40a8d6abe57f6be (diff) | |
download | matterbridge-msglm-76e5fe5a87d7e60919075f96eee599f3c6255a9f.tar.gz matterbridge-msglm-76e5fe5a87d7e60919075f96eee599f3c6255a9f.tar.bz2 matterbridge-msglm-76e5fe5a87d7e60919075f96eee599f3c6255a9f.zip |
Update vendor yaegashi/msgraph.go to v0.1.2 (2)
Diffstat (limited to 'vendor/github.com/rickb777/date/period/marshal.go')
-rw-r--r-- | vendor/github.com/rickb777/date/period/marshal.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/github.com/rickb777/date/period/marshal.go b/vendor/github.com/rickb777/date/period/marshal.go new file mode 100644 index 00000000..c87ad5f6 --- /dev/null +++ b/vendor/github.com/rickb777/date/period/marshal.go @@ -0,0 +1,32 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package period + +// MarshalBinary implements the encoding.BinaryMarshaler interface. +// This also provides support for gob encoding. +func (period Period) MarshalBinary() ([]byte, error) { + // binary method would take more space in many cases, so we simply use text + return period.MarshalText() +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. +// This also provides support for gob encoding. +func (period *Period) UnmarshalBinary(data []byte) error { + return period.UnmarshalText(data) +} + +// MarshalText implements the encoding.TextMarshaler interface for Periods. +func (period Period) MarshalText() ([]byte, error) { + return []byte(period.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface for Periods. +func (period *Period) UnmarshalText(data []byte) (err error) { + u, err := Parse(string(data)) + if err == nil { + *period = u + } + return err +} |