MCPcopy Create free account
hub / github.com/crewjam/saml / optionalRelaxedTime

Function optionalRelaxedTime

time.go:23–29  ·  view source on GitHub ↗

optionalRelaxedTime returns t as a *RelaxedTime, or nil if t is the zero time. It is used for optional time attributes, so that MarshalXML leaves out an unset time as Element does, instead of writing "0001-01-01T00:00:00Z" (which reads as long expired).

(t time.Time)

Source from the content-addressed store, hash-verified

21// out an unset time as Element does, instead of writing
22// "0001-01-01T00:00:00Z" (which reads as long expired).
23func optionalRelaxedTime(t time.Time) *RelaxedTime {
24 if t.IsZero() {
25 return nil
26 }
27 rt := RelaxedTime(t)
28 return &rt
29}
30
31// MarshalText implements encoding.TextMarshaler
32func (m RelaxedTime) MarshalText() ([]byte, error) {

Callers 2

MarshalXMLMethod · 0.85
MarshalXMLMethod · 0.85

Calls 1

RelaxedTimeTypeAlias · 0.85

Tested by

no test coverage detected