tmpl

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: MIT Imports: 6 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string, t time.Time) string

Parse will parse a template string according to the provided instance of time.Time. It supports the following template tokens:

{YYYY} (year - four digits: ie 2017) {YY} (year - two digits: ie 17) {MM} (month - two digits: ie 12) {DD} (day - two digits: ie 13) {HH} (hour - two digits: ie 00) {TS} (timestamp in the format 20060102T150405) {SLUG} (alias of HOUR_SLUG) {HOUR_SLUG} (date hour slug, shorthand for {YYYY}/{MM}/{DD}/{HH}) {DAY_SLUG} (date day slug, shorthand for {YYYY}/{MM}/{DD}) {MONTH_SLUG} (date month slug, shorthand for {YYYY}/{MM})

Template values are case sensitive.

Examples: template: "{YYYY}-{MM}-{DD}T{HH}:00" could return: "2017-01-01T23:00"

template: "{TS}" could return: "20170101T230101"

template: "base/path/{SLUG}/records-{TS}.json.gz" could return: "base/path/2017/01/01/23/records-20170101T230101.json.gz"

func PathTime

func PathTime(pth string) time.Time

PathTime will attempt to extract a time value from the path by the following formats filename - /path/{20060102T150405}.txt hour slug - /path/2006/01/02/15/file.txt day slug - /path/2006/01/02/file.txt month slug - /path/2006/01/file.txt

Types

This section is empty.

Jump to

Keyboard shortcuts

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