date

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Date

func Date(layout string) string

Date returns the current time formatted with the given layout

func RunDate

func RunDate(w io.Writer, opts DateOptions) error

RunDate prints the current date and time

Types

type DateOptions

type DateOptions struct {
	Format string // custom format string
	UTC    bool   // -u: use UTC time
	ISO    bool   // --iso-8601: output date/time in ISO 8601 format
	JSON   bool   // --json: output as JSON
}

DateOptions configures the date command behavior

type DateResult

type DateResult struct {
	Formatted string `json:"formatted"`
	Unix      int64  `json:"unix"`
	UnixNano  int64  `json:"unix_nano"`
	Year      int    `json:"year"`
	Month     int    `json:"month"`
	Day       int    `json:"day"`
	Hour      int    `json:"hour"`
	Minute    int    `json:"minute"`
	Second    int    `json:"second"`
	Weekday   string `json:"weekday"`
	Timezone  string `json:"timezone"`
	UTC       bool   `json:"utc"`
}

DateResult represents date output for JSON

Jump to

Keyboard shortcuts

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