dater

package
v1.32.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: AGPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Date_dashed_yyyymmdd is the date format for "YYYY-MM-DD"
	Date_dashed_yyyymmdd = &DateFormat{"YYYY-MM-DD", "2006-01-02"}
)
View Source
var ErrInvalidDate = errors.New("invalid date")

ErrInvalidDate is returned when trying to validate and/or parse a date string, there was no success.

This might happen because of two reasons: 1. Date string is actually invalid 2. Format of the date string is not supported

Functions

This section is empty.

Types

type DateFormat

type DateFormat struct {
	// contains filtered or unexported fields
}

DateFormat is a wrapper to hold the golang layout used to parse dates and a display value that can be used to be shown to users to explain the format it represents

type Dater

type Dater interface {
	// Now returns the current local time
	Now() *time.Time
	// Parse parses a formatted string and returns the time value it represents
	Parse(format *DateFormat, value string) (*time.Time, error)
	// ParseAll tries to parse a formatted string by passing it through all
	// supported date layouts and returns the time valye it represents
	ParseAll(value string) (*time.Time, error)
}

Dater is a wrapper to handle date operations

This is useful for testing

func NewDater

func NewDater() Dater

NewDater creates a new instance of Dater

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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