Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date format: cannot unmarshal into soap.XSDDate #262

Open
giuliohome opened this issue Oct 19, 2023 · 0 comments
Open

date format: cannot unmarshal into soap.XSDDate #262

giuliohome opened this issue Oct 19, 2023 · 0 comments

Comments

@giuliohome
Copy link

giuliohome commented Oct 19, 2023

I have seen "Date/time types fail to unmarshal" issue #38 and "Xsd date and time support" PR #195
I have noticed xsd:date Datatype Reference https://books.xmlschemata.org/relaxng/ch19-77041.html

[-]CCYY-MM-DD[Z|(+|-)hh:mm]

Note the Example where it is clearly stated that

Valid values include: 2001-10-26,...

I think that the case of a xsd:date like "2023-10-11" - i.e. without the optional T time part - is not covered by the current implementation.
Maybe that's a bug that could be fixed.
Indeed, given a generated struct attribute

  SchemaRevisionDate soap.XSDDate `xml:"schemaRevisionDate,attr,omitempty" json:"schemaRevisionDate,omitempty"

I was getting the error:

could't get change request: cannot unmarshal into soap.XSDDate

Meanwhile I've worked it around by defining

type customDate struct {
	t time.Time
}

func (c *customDate) UnmarshalXMLAttr(attr xml.Attr) error {
	const myFormat = "2006-01-02"
	parse, err := time.Parse(myFormat, attr.Value)
	if err != nil {
		return err
	}
	c.t = parse
	return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant