wrappers

package
v2.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrYearOutsideOfRange = errors.New("Wrappers.Time.MarshalText: year outside of range [0,9999]")

ErrYearOutsideOfRange is the error returned when the year is outside 0 and 9999

Functions

func WithKDBX4Formatting added in v2.1.0

func WithKDBX4Formatting(t *TimeWrapper)

Types

type BoolWrapper

type BoolWrapper bool

BoolWrapper is a bool wrapper that provides xml marshaling and unmarshaling

func (*BoolWrapper) MarshalXML

func (b *BoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals the boolean into e

func (*BoolWrapper) MarshalXMLAttr

func (b *BoolWrapper) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr returns the encoded XML attribute

func (*BoolWrapper) UnmarshalXML

func (b *BoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the boolean from d

func (*BoolWrapper) UnmarshalXMLAttr

func (b *BoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr decodes a single XML attribute

type TimeOption added in v2.1.0

type TimeOption func(*TimeWrapper)

func WithFormatted added in v2.1.0

func WithFormatted(formatted bool) TimeOption

type TimeWrapper

type TimeWrapper struct {
	Formatted bool      // True for Kdbx v3.1 (formatted as RFC3339)
	Time      time.Time // Time value
}

TimeWrapper is a time.Time wrapper that provides xml marshaling and unmarshaling

func Now

func Now(options ...TimeOption) TimeWrapper

Now returns a TimeWrapper instance with the current time in UTC

func (TimeWrapper) MarshalText

func (tw TimeWrapper) MarshalText() ([]byte, error)

MarshalText marshals time into an RFC3339 compliant value in UTC (Kdbx v3.1) On Kdbx v4 it calculates the timestamp subtracting seconds from the time date and encode it with base64

func (TimeWrapper) String

func (tw TimeWrapper) String() string

func (*TimeWrapper) UnmarshalText

func (tw *TimeWrapper) UnmarshalText(data []byte) error

UnmarshalText take a string of format time.RFC3339 and marshals it into the TimeWrapper value (Kdbx v3.1) On Kdbx v4 it calculates the time with given seconds via data byte array (base64 encoded)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL