dates

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Functions

This section is empty.

Types

type Converter

type Converter struct {
	GVK       schema.GroupVersionKind
	Columns   []rescommon.ColumnDefinition
	IsCRD     bool
	JSONPaths map[string]*jsonpath.JSONPath
}

Converter handles the transformation of date/time columns in resources. There are two cases:

  1. CRD Date Columns: For CRDs, columns defined with type `date` are expected by the UI to contain a timestamp, not a duration. We use the associated JSONPath to extract the raw value from the object. This ensures we pass the correct timestamp format to the UI. We do it in the transformer so that we can correctly sort / filter in the SQLite database.

  2. Built-in Date Columns Kubernetes often returns time fields (like "Age") as human-readable durations (e.g., "6h4m"). Storing this static string in the cache is problematic because it becomes stale immediately. For example, if we store "6h4m", an hour later the resource is effectively "7h4m" old, but the cache still serves "6h4m".

    To fix this, we parse the duration string, subtract it from the current time to calculate the approximate absolute timestamp, and store that timestamp (in Unix milliseconds). The UI can then use this timestamp to display a live, accurate relative time (e.g., "7 hours ago").

func (*Converter) Transform

Jump to

Keyboard shortcuts

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