time

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Day   = 24 * xtime.Hour
	Week  = 7 * Day
	Month = 30 * Day
	Year  = 365 * Day
)
View Source
const FormatLayout = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func Format

func Format(t xtime.Time, layout string) string

Format returns a textual representation of the time value formatted according to layout, which defines the format by showing how the reference time Example Format(time.Now(), "YYYY-MM-DD HH:mm:ss")

layout defined by:

  1. YYYY = 2006,YY = 06
  2. MM = 01, MMM = Jan,MMMM = January
  3. DD = 02,
  4. DDD = Mon,DDDD = Monday
  5. HH = 15,hh = 03, h = 3
  6. mm = 04, m = 4
  7. ss = 05, m = 5

func InRange

func InRange(t xtime.Time, start, end xtime.Time) bool

func Parse

func Parse(layout string, value string) (xtime.Time, error)

func Random

func Random(max xtime.Duration) xtime.Duration

func Tick

func Tick(ctx context.Context, d xtime.Duration, f func() error) error

Types

type Duration

type Duration xtime.Duration

Duration be used toml unmarshal string time, like 1s, 500ms.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) Shrink

Shrink will decrease the duration by comparing with context's timeout duration and return new timeout\context\CancelFunc.

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText unmarshal text to duration.

type Item

type Item struct {
	Go  string
	Std string
}

Jump to

Keyboard shortcuts

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