lwtime

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

A simple relative and natural time package

A simple relative and natural time package

Index

Constants

View Source
const (
	Today     naturalAdjective = "today"
	Yesterday naturalAdjective = "yesterday"
	This      naturalAdjective = "this"
	Current   naturalAdjective = "current"
	Previous  naturalAdjective = "previous"
	Last      naturalAdjective = "last"
)
View Source
const (
	Year   relativeUnit = "y"
	Month  relativeUnit = "mon"
	Week   relativeUnit = "w"
	Day    relativeUnit = "d"
	Hour   relativeUnit = "h"
	Minute relativeUnit = "m"
	Second relativeUnit = "s"
)
View Source
const (
	RFC3339Milli = "2006-01-02T15:04:05.000Z"
)

Variables

This section is empty.

Functions

func ParseNatural

func ParseNatural(n string) (time.Time, time.Time, error)

Parse the string representation of a Lacework natural time

start, end, err := lwtime.ParseNatural("this year")

if err != nil {
	...
}

func ParseRelative

func ParseRelative(s string) (time.Time, error)

Parse the string representation of a Lacework relative time

t, err := lwtime.ParseRelative("-1y@y")

if err != nil {
	...
}

Types

type Epoch added in v0.9.1

type Epoch time.Time

Epoch time type to parse the returned 13 digit time in milliseconds

func (Epoch) Format added in v0.9.1

func (epoch Epoch) Format(s string) string

func (*Epoch) MarshalJSON added in v0.9.1

func (epoch *Epoch) MarshalJSON() ([]byte, error)

func (Epoch) ToTime added in v0.9.1

func (epoch Epoch) ToTime() time.Time

A few format functions for printing and manipulating the custom date

func (Epoch) UTC added in v0.9.1

func (epoch Epoch) UTC() time.Time

func (*Epoch) UnmarshalJSON added in v0.9.1

func (epoch *Epoch) UnmarshalJSON(b []byte) error

implement Marshal and Unmarshal interfaces

type EpochString added in v0.9.1

type EpochString time.Time

EpochString time type to parse the returned 13 digit time in milliseconds Used instead of Epoch type when unmarshalling a json response where epoch time is a string

func (EpochString) Format added in v0.9.1

func (epoch EpochString) Format(s string) string

func (*EpochString) MarshalJSON added in v0.9.1

func (epoch *EpochString) MarshalJSON() ([]byte, error)

func (EpochString) ToTime added in v0.9.1

func (epoch EpochString) ToTime() time.Time

func (EpochString) UTC added in v0.9.1

func (epoch EpochString) UTC() time.Time

func (*EpochString) UnmarshalJSON added in v0.9.1

func (epoch *EpochString) UnmarshalJSON(b []byte) error

type NanoTime added in v0.9.1

type NanoTime time.Time

time type to parse the returned time with nano format

Example:

"START_TIME":"2020-08-20T01:00:00+0000"

func (NanoTime) Format added in v0.9.1

func (self NanoTime) Format(s string) string

func (NanoTime) MarshalJSON added in v0.9.1

func (self NanoTime) MarshalJSON() ([]byte, error)

func (NanoTime) ToTime added in v0.9.1

func (self NanoTime) ToTime() time.Time

A few format functions for printing and manipulating the custom date

func (NanoTime) UTC added in v0.9.1

func (self NanoTime) UTC() time.Time

func (*NanoTime) UnmarshalJSON added in v0.9.1

func (self *NanoTime) UnmarshalJSON(b []byte) (err error)

type RFC1123Z added in v0.9.1

type RFC1123Z time.Time

func (RFC1123Z) Format added in v0.9.1

func (rfc RFC1123Z) Format(s string) string

func (*RFC1123Z) MarshalJSON added in v0.9.1

func (rfc *RFC1123Z) MarshalJSON() ([]byte, error)

func (RFC1123Z) ToTime added in v0.9.1

func (rfc RFC1123Z) ToTime() time.Time

func (RFC1123Z) UTC added in v0.9.1

func (rfc RFC1123Z) UTC() time.Time

func (*RFC1123Z) UnmarshalJSON added in v0.9.1

func (rfc *RFC1123Z) UnmarshalJSON(b []byte) (err error)

Jump to

Keyboard shortcuts

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