types

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC822TimeFormatName  = "rfc822"
	ISO8601TimeFormatName = "iso8601"
	UnixTimeFormatName    = "unixTimestamp"
)

Names of time formats supported by the SDK

View Source
const (
	// RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT
	RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"

	// This format is used for output time without seconds precision
	RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

	// RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z
	ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"

	// This format is used for output time with fractional second precision up to milliseconds
	ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
)

Time formats supported by the SDK Output time is intended to not contain decimals

Variables

This section is empty.

Functions

func EncodeJSONValue

func EncodeJSONValue(v JSONValue, escape EscapeMode) (string, error)

EncodeJSONValue marshals the value into a JSON string, and optionally base64 encodes the string before returning it.

Will panic if the escape mode is unknown.

func FormatTime

func FormatTime(name string, t time.Time) string

FormatTime returns a string value of the time.

func IsKnownTimestampFormat

func IsKnownTimestampFormat(name string) bool

IsKnownTimestampFormat returns if the timestamp format name is know to the SDK's protocols.

func ParseTime

func ParseTime(formatName, value string) (time.Time, error)

ParseTime attempts to parse the time given the format. Returns the time if it was able to be parsed, and fails otherwise.

Types

type EscapeMode

type EscapeMode uint

EscapeMode is the mode that should be use for escaping a value

const (
	NoEscape EscapeMode = iota
	Base64Escape
	QuotedEscape
)

The modes for escaping a value before it is marshaled, and unmarshaled.

type JSONValue

type JSONValue map[string]interface{}

JSONValue is a representation of a grab bag type that will be marshaled into a json string. This type can be used just like any other map.

Example:

values := JSONValue{
	"Foo": "Bar",
}
values["Baz"] = "Qux"

func DecodeJSONValue

func DecodeJSONValue(v string, escape EscapeMode) (JSONValue, error)

DecodeJSONValue will attempt to decode the string input as a JSONValue. Optionally decoding base64 the value first before JSON unmarshaling.

Will panic if the escape mode is unknown.

Jump to

Keyboard shortcuts

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