Documentation ¶
Index ¶
- type Namespace
- func (ns *Namespace) Ago(i interface{}) string
- func (ns *Namespace) Date(fmt string, date interface{}) (string, error)
- func (ns *Namespace) DateInZone(format string, date interface{}, zone string) (string, error)
- func (ns *Namespace) Duration(sec interface{}) string
- func (ns *Namespace) HTMLDate(date interface{}) (string, error)
- func (ns *Namespace) HTMLDateInZone(date interface{}, zone string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace defines the methods for dates to be used as template functions.
func (*Namespace) Ago ¶
Ago
Returns a duration from the given time input in seconds. a date can be a `time.Time` or an `int, int64`.
Example: {{ ago .UpdatedAt }}
func (*Namespace) Date ¶
Date
Format date by `interface{}` input, a date can be a `time.Time` or an `int, int32, int64`.
Example: {{ date "02/01/2006" now }}
func (*Namespace) DateInZone ¶
DateInZone
Takes a format, the date and zone. Casts the date to the correct format.
Returns errors.TEMPLATE if the the interface could not be cast to type time.Time
Example: {{ dateInZone "02/01/2006" now "Europe/London" }}
func (*Namespace) Duration ¶
Duration
Formats a given amount of seconds as a `time.Duration` For example `duration 85` will return `1m25s`.
Example: {{ duration 85 }}