durationscanner

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package durationscanner implements a tokenizer/lexer that analyses Elk duration strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Durationscanner

type Durationscanner struct {
	// contains filtered or unexported fields
}

Scans a duration string and produces tokens for each datetime component.

func New

func New(durString string) *Durationscanner

func (*Durationscanner) Next

func (t *Durationscanner) Next() (Token, string)

type Token

type Token uint8
const (
	ZERO_VALUE         Token = iota // Zero value for Type
	ERROR                           // Invalid format directive
	END_OF_FILE                     // End Of File has been reached
	YEARS_INT                       // Year component eg. "2Y"
	YEARS_FLOAT                     // Year component eg. "2.5Y"
	MONTHS_INT                      // Month component eg. "15M"
	MONTHS_FLOAT                    // Month component eg. "15.9M"
	DAYS_INT                        // Day component eg. "1D"
	DAYS_FLOAT                      // Day component eg. "1.8D"
	HOURS_INT                       // Hour component eg. "9h"
	HOURS_FLOAT                     // Hour component eg. "9.15h"
	MINUTES_INT                     // Minute component eg. "10m"
	MINUTES_FLOAT                   // Minute component eg. "10.76m"
	SECONDS_INT                     // Second component eg. "50s"
	SECONDS_FLOAT                   // Second component eg. "50.78s"
	MILLISECONDS_INT                // Millisecond component eg. "150ms"
	MILLISECONDS_FLOAT              // Millisecond component eg. "150.8ms"
	MICROSECONDS_INT                // Microsecond component eg. "600us", "600µs"
	MICROSECONDS_FLOAT              // Microsecond component eg. "600.256us", "600µs"
	NANOSECONDS_INT                 // Nanosecond component eg. "750ns"
	NANOSECONDS_FLOAT               // Nanosecond component eg. "750.72ns"
)

func (Token) String

func (t Token) String() string

Name of the token.

Jump to

Keyboard shortcuts

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