Compare commits
No commits in common. "30a3d18277d159ab0cd0d8444fe1a10885121259" and "9f0dd430e8f2d5c6c9cd77131282971612ca8770" have entirely different histories.
30a3d18277
...
9f0dd430e8
|
@ -12,19 +12,14 @@ import (
|
||||||
|
|
||||||
type OCSSTime time.Time
|
type OCSSTime time.Time
|
||||||
|
|
||||||
func (t OCSSTime) MarshalJSON() ([]byte, error) {
|
func (t *OCSSTime) MarshalJSON() ([]byte, error) {
|
||||||
// do your serializing here
|
// do your serializing here
|
||||||
stamp := fmt.Sprintf("%v", time.Time(t).Unix())
|
stamp := fmt.Sprintf("%v", time.Time(*t).Unix())
|
||||||
return []byte(stamp), nil
|
return []byte(stamp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v OCSSTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
|
func (v *OCSSTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
|
||||||
return bson.MarshalValue(time.Time(v))
|
return bson.MarshalValue(time.Time(*v))
|
||||||
}
|
|
||||||
|
|
||||||
func (t OCSSTime) ToTime() time.Time {
|
|
||||||
time := time.Time(t)
|
|
||||||
return time
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *OCSSTime) UnmarshalJSON(b []byte) error {
|
func (t *OCSSTime) UnmarshalJSON(b []byte) error {
|
||||||
|
@ -56,9 +51,11 @@ func (t *OCSSTime) UnmarshalBSONValue(bt bsontype.Type, b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *OCSSTime) Format(format string) string {
|
func (t *OCSSTime) ToTime() *time.Time {
|
||||||
if format == "" {
|
if t == nil {
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
return t.ToTime().Format(format)
|
|
||||||
|
time := time.Time(*t)
|
||||||
|
return &time
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue