Documentation
¶
Overview ¶
Package view provides a simple API for formatting dates as strings in a manner that is easy to use in view-models, especially when using Go templates.
Index ¶
- Constants
- type VDate
- func (d VDate) Day02() string
- func (d VDate) Day2() string
- func (d VDate) Day2nd() string
- func (d VDate) Format() string
- func (d VDate) Jan() string
- func (d VDate) January() string
- func (v VDate) MarshalText() ([]byte, error)
- func (d VDate) Mon() string
- func (d VDate) Monday() string
- func (d VDate) Month01() string
- func (d VDate) Month1() string
- func (d VDate) Next() VDateDelta
- func (d VDate) Previous() VDateDelta
- func (d VDate) String() string
- func (v *VDate) UnmarshalText(data []byte) (err error)
- func (d VDate) WithFormat(f string) VDate
- func (d VDate) Year() string
- type VDateDelta
Constants ¶
const ( // DMYFormat is a typical British representation. DMYFormat = "02/01/2006" // MDYFormat is a typical American representation. MDYFormat = "01/02/2006" // DefaultFormat is used by Format() unless a different format is set. DefaultFormat = DMYFormat )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type VDate ¶
type VDate struct {
// contains filtered or unexported fields
}
A VDate holds a Date and provides easy ways to render it, e.g. in Go templates.
func (VDate) Day2nd ¶
Day2nd returns the day number without a leading zero but with the appropriate "st", "nd", "rd", "th" suffix.
func (VDate) Format ¶
Format formats the date using the specified format string, or "02/01/2006" by default. Use WithFormat to set this up.
func (VDate) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (VDate) Next ¶
func (d VDate) Next() VDateDelta
Next returns a fluent generator for later dates.
func (VDate) Previous ¶
func (d VDate) Previous() VDateDelta
Previous returns a fluent generator for earlier dates.
func (*VDate) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. Note that the format value gets lost.
func (VDate) WithFormat ¶
WithFormat creates a new instance containing the specified format string.
type VDateDelta ¶
type VDateDelta struct {
// contains filtered or unexported fields
}