From 0db75c9211a32649fb362a8a3cefff1b97505685 Mon Sep 17 00:00:00 2001 From: John Beisley Date: Wed, 9 Oct 2013 21:38:41 +0100 Subject: [PATCH] Document/fix the "date" marshalling. --- soap/types.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/soap/types.go b/soap/types.go index 342d652..8a1c7a6 100644 --- a/soap/types.go +++ b/soap/types.go @@ -45,12 +45,16 @@ func UnmarshalChar(s string) (rune, error) { return r, nil } +// MarshalDate marshals time.Time to SOAP "date" type. Note that this converts +// to local time, and discards the time-of-day components. func MarshalDate(v time.Time) (string, error) { - return v.Format("2006-01-02"), nil + return v.Local().Format("2006-01-02"), nil } var dateFmts = []string{"2006-01-02", "20060102"} +// UnmarshalDate unmarshals time.Time from SOAP "date" type. This outputs the +// date as midnight in the local time zone. func UnmarshalDate(s string) (time.Time, error) { for _, f := range dateFmts { if t, err := time.ParseInLocation(f, s, time.Local); err == nil {