format

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) string

Bool formats a bool as yes/no.

func Duration

func Duration(d time.Duration) string

Duration formats a duration.

func Int

func Int(i int) string

Int formats an int.

func Int64

func Int64(i int64) string

Int64 formats an int64.

func NextScheduleForJobConfig

func NextScheduleForJobConfig(
	jobConfig *execution.JobConfig,
	cronParser *cron.Parser,
	format TimeFormatFunc,
	opts ...Option,
) (string, error)

NextScheduleForJobConfig formats a JobConfig's next schedule with the given cron parser.

func Time

func Time(t *metav1.Time, opts ...Option) string

Time formats a time using a human-readable format.

func TimeAgo

func TimeAgo(t *metav1.Time, opts ...Option) string

TimeAgo formats a time as a string representing the duration since the given time.

func TimeWithTimeAgo

func TimeWithTimeAgo(t *metav1.Time, opts ...Option) string

TimeWithTimeAgo formats a time together with a relative time ago as a string.

Types

type Config

type Config struct {
	// DefaultValue is used in case of a zero value.
	DefaultValue string
}

Config represents formatting configuration values.

type Option

type Option func(c *Config)

Option represents functional options for various format functions.

func WithDefaultValue

func WithDefaultValue(value string) Option

WithDefaultValue specifies a default value for the formatter.

type TimeFormatFunc

type TimeFormatFunc func(t *metav1.Time, opts ...Option) string

TimeFormatFunc is a function that formats a given *metav1.Time into a string format.

Jump to

Keyboard shortcuts

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