Captain ALM
0b2ba868a3
All checks were successful
continuous-integration/drone/push Build is passing
Update page handling system. Update Makefile and .gitignore .
32 lines
506 B
Go
32 lines
506 B
Go
package yaml
|
|
|
|
import (
|
|
"gopkg.in/yaml.v3"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
const dateFormat = "02/01/2006"
|
|
|
|
type DateType struct {
|
|
time.Time
|
|
}
|
|
|
|
func (dt *DateType) MarshalYAML() (interface{}, error) {
|
|
return dt.Time.Format(dateFormat), nil
|
|
}
|
|
|
|
func (dt *DateType) UnmarshalYAML(value *yaml.Node) error {
|
|
var stringIn string
|
|
err := value.Decode(&stringIn)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
pt, err := time.Parse(dateFormat, strings.TrimSpace(stringIn))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
dt.Time = pt
|
|
return nil
|
|
}
|