util

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTimeParam

func ParseTimeParam(timeStr string) (time.Time, error)

ParseTimeParam parses time parameters supporting multiple formats: - "now" for current time - Unix timestamps (e.g., "1704067200") - Relative time with flexible formats:

  • Short: "1h", "30m", "7d", "5s", "1w"
  • Long: "5min", "5mins", "5minute", "5minutes"
  • Long: "2hr", "2hrs", "2hour", "2hours"
  • Long: "3day", "3days"
  • Long: "1week", "1weeks"
  • With spaces: "5 minutes", "2 hours"
  • With minus prefix: "-5m", "-2h" (treated same as "5m", "2h")

- ISO date strings (e.g., "2024-01-01T00:00:00Z")

func ParseTimeToUnix

func ParseTimeToUnix(timeStr string) (int64, error)

ParseTimeToUnix parses time string and returns Unix timestamp in seconds

func ParseTimeToUnixMilli

func ParseTimeToUnixMilli(timeStr string) (int64, error)

ParseTimeToUnixMilli parses time string and returns Unix timestamp in milliseconds. Uses Unix()*1000 instead of UnixMilli() to produce second-aligned timestamps. time.Now() and duration arithmetic produce nanosecond precision, and UnixMilli() preserves the sub-second component which some Datadog APIs reject or misinterpret.

Types

This section is empty.

Jump to

Keyboard shortcuts

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