Documentation
Overview ¶
Package xtime implements time related XMPP functionality.
In particular, this package implements XEP-0202: Entity Time and XEP-0082: XMPP Date and Time Profiles.
Index ¶
Examples ¶
Constants ¶
View Source
const ( // NS is the XML namespace used by XMPP entity time requests. // It is provided as a convenience. NS = "urn:xmpp:time" // LegacyDateTime implements the legacy profile mentioned in XEP-0082. // // Unless you are implementing an older XEP that specifically calls for this // format, time.RFC3339 should be used instead. LegacyDateTime = "20060102T15:04:05" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
Handler responds to requests for our time. If timeFunc is nil, time.Now is used.
func (Handler) HandleIQ ¶
func (h Handler) HandleIQ(iq stanza.IQ, t xmlstream.TokenReadEncoder, start *xml.StartElement) error
HandleIQ responds to entity time requests.
type Time ¶
Time is like a time.Time but it can be marshaled as an XEP-0202 time payload.
Example ¶
Code:
package main import ( "encoding/xml" "fmt" "mellium.im/xmpp/xtime" "time" ) func main() { t, _ := time.Parse(time.RFC3339, "2020-02-19T06:46:00-05:00") xt := xtime.Time(t) o, _ := xml.Marshal(xt) fmt.Printf("%s\n", o) }
<time xmlns="urn:xmpp:time"><tzo>-05:00</tzo><utc>2020-02-19T11:46:00Z</utc></time>
func (Time) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (Time) TokenReader ¶
func (t Time) TokenReader() xml.TokenReader
TokenReader satisfies the xmlstream.Marshaler interface.
func (*Time) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler.