Documentation ¶
Overview ¶
fmtdate provides a date formatter and parser using the syntax of Microsoft Excel (TM).
Additionally it offers default conversions for date time and datetime.
Why?
Microsoft Excel (TM) has a well known syntax for date formatting, that more memorable than the syntax chosen in the time package in the go library.
Usage
package main import ( "gopkg.in/metakeule/fmtdate.v1" "fmt" ) func main() { date := fmtdate.Format("DD.MM.YYYY", time.Now()) fmt.Println(date) var err date, err = fmtdate.Parse("M/D/YY", "2/3/07") fmt.Println(date, err) }
Index ¶
- Variables
- func Format(format string, date time.Time) string
- func FormatDate(date time.Time) string
- func FormatDateTime(date time.Time) string
- func FormatTime(date time.Time) string
- func Parse(format string, value string) (time.Time, error)
- func ParseDate(value string) (time.Time, error)
- func ParseDateTime(value string) (time.Time, error)
- func ParseTime(value string) (time.Time, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultTimeFormat = "hh:mm:ss" DefaultDateFormat = "YYYY-MM-DD" DefaultDateTimeFormat = "YYYY-MM-DD hh:mm:ss" )
View Source
var Placeholder = []p{
p{"hh", "15"},
p{"h", "03"},
p{"mm", "04"},
p{"ss", "05"},
p{"MMMM", "January"},
p{"MMM", "Jan"},
p{"MM", "01"},
p{"M", "1"},
p{"pm", "PM"},
p{"ZZZZ", "-0700"},
p{"ZZZ", "MST"},
p{"ZZ", "Z07:00"},
p{"YYYY", "2006"},
p{"YY", "06"},
p{"DDDD", "Monday"},
p{"DDD", "Mon"},
p{"DD", "02"},
p{"D", "2"},
}
Functions ¶
func FormatDate ¶
FormatDate formats the given date to the DefaultDateFormat
func FormatDateTime ¶
FormatTime formats the given date to the DefaultDateTimeFormat
func FormatTime ¶
FormatTime formats the given date to the DefaultTimeFormat
func ParseDateTime ¶
Parse parses a date in DefaultDateTimeFormat to a date
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.