period

package
v0.0.0-...-5e10106 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPeriod error = errors.New("invalid-period")
)

Functions

func RoundTimestamp

func RoundTimestamp(t timestamp.Timestamp, p Period) timestamp.Timestamp

Types

type Period

type Period int64
const (
	// M1 represents 1 minute in epoch time
	M1 Period = 60
	// M3 represents 3 minutes in epoch time
	M3 Period = 3 * 60
	// M5 represents 5 minutes in epoch time
	M5 Period = 5 * 60
	// M15 represents 15 minutes in epoch time
	M15 Period = 15 * 60
	// M30 represents 30 minutes in epoch time
	M30 Period = 30 * 60
	// H1 represents 1 hour in epoch time
	H1 Period = 1 * 60 * 60
	// H2 represents 2 hours in epoch time
	H2 Period = 2 * 60 * 60
	// H4 represents 4 hours in epoch time
	H4 Period = 4 * 60 * 60
	// H6 represents 6 hours in epoch time
	H6 Period = 6 * 60 * 60
	// H8 represents 8 hours in epoch time
	H8 Period = 8 * 60 * 60
	// H12 represents 12 hours in epoch time
	H12 Period = 12 * 60 * 60
	// D1 represents 1 day in epoch time
	D1 Period = 1 * 24 * 60 * 60
	// D3 represents 3 days in epoch time
	D3 Period = 3 * 24 * 60 * 60
	// W1 represents 1 week in epoch time
	W1 Period = 1 * 7 * 24 * 60 * 60
)

func FromName

func FromName(name string) (Period, error)

func FromSeconds

func FromSeconds(i int64) (Period, error)

func Periods

func Periods() []Period

func UniqueArray

func UniqueArray(per1, per2 []Period) []Period

func (Period) CountBetweenTimestamps

func (p Period) CountBetweenTimestamps(start, end timestamp.Timestamp) int64

func (Period) Duration

func (p Period) Duration() time.Duration

func (Period) IsAligned

func (p Period) IsAligned(t timestamp.Timestamp) bool

func (Period) Name

func (p Period) Name() (string, error)

func (Period) String

func (p Period) String() string

Jump to

Keyboard shortcuts

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