// 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)
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)
// 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 )
func (tw *TimeWrapper) UnmarshalText(data []byte) error {
	var formatted bool
	t, err := time.Parse(time.RFC3339, string(data))
	if err != nil {
		var buf int64
		decoded := make([]byte, base64.StdEncoding.DecodedLen(len(data)))
		_, err = base64.StdEncoding.Decode(decoded, data)
		if err != nil {
			return err
		}
		if err := binary.Read(bytes.NewReader(decoded), binary.LittleEndian, &buf); err != nil {
			return err
		}
		t = time.Unix(zeroUnixOffset+buf, 0)
		formatted = false
	} else {
		formatted = true
	}
	*tw = TimeWrapper{
		Formatted: formatted,
		Time:      t,
	}
	return nil
}
func ( tw * TimeWrapper ) UnmarshalText ( data [ ] byte ) error { var formatted bool t , err := time . Parse ( time . RFC3339 , string ( data ) ) if err != nil { var buf int64 decoded := make ( [ ] byte , base64 . StdEncoding . DecodedLen ( len ( data ) ) ) _ , err = base64 . StdEncoding . Decode ( decoded , data ) if err != nil { return err } if err := binary . Read ( bytes . NewReader ( decoded ) , binary . LittleEndian , & buf ) ; err != nil { return err } t = time . Unix ( zeroUnixOffset + buf , 0 ) formatted = false } else { formatted = true } * tw = TimeWrapper { Formatted : formatted , Time : t , } return nil }
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)
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 )
// Check for RFC string (KDBX 3.1), if it fail try with KDBX 4 // KDBX v4 // In version 4 the time is a base64 timestamp of seconds passed since 1/1/0001 // Count since year 1