utils

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateFromISOWeek

func DateFromISOWeek(isoYear int, isoWeek int) (date time.Time)

Calculate the actual date which represents the start of the given ISOWeek

func ExtractGzip

func ExtractGzip(file, destDir string, skipHidden bool) (root string, err error)

ExtractGzip extracts a gzipped archive to the specified directory and returns the path to the root level of the extracted archive. Caller must ensure that the destination directory exists.

func Latest added in v1.5.3

func Latest(a, b string) string

Helper method to return the latest string timestamp from the two RFC3339 timestamps

func ValidateCommonName added in v1.7.0

func ValidateCommonName(name string) (err error)

Validate a common name. The common name should not be empty, nor start with an "*" (e.g. a DNS wildcard). It should not start with a - and each label should be no more than 63 octets long. The common name should not have a scheme e.g. https:// prefix and it shouldn't have a port, e.g. example.com:443. Parsing is primarily based on a regular expression match from the cnre pattern.

func WithDeadline added in v1.7.0

func WithDeadline(ctx context.Context) (context.Context, context.CancelFunc)

func WriteGzip

func WriteGzip(dir, file string) (err error)

WriteGzip compresses a directory to a gzipped archive.

Types

type Week

type Week struct {
	Date    time.Time
	Year    int
	WeekNum int
}

func NewWeek

func NewWeek(date time.Time) (week *Week)

Returns a new Week object given a time.Time

func (*Week) Sub

func (w *Week) Sub(u *Week) int

Returns the difference w-u between two Weeks, in terms of number of weeks

type WeekIterator

type WeekIterator struct {
	Start   *Week
	Current *Week
	End     *Week
}

func GetWeekIterator

func GetWeekIterator(start time.Time, end time.Time) (iter *WeekIterator, err error)

Takes in a time range and returns a WeekIterator

func (*WeekIterator) Next

func (i *WeekIterator) Next() (week *Week, ok bool)

Returns the next Week from the WeekIterator

Directories

Path Synopsis
Package wire is a store helper package that handles "wire" representations of the objects being managed in the store - e.g.
Package wire is a store helper package that handles "wire" representations of the objects being managed in the store - e.g.

Jump to

Keyboard shortcuts

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