make datePatterns hide

This commit is contained in:
astaxie 2013-12-21 20:44:34 +08:00
parent 8ba6dbb9a0
commit 2c868a9557
1 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,7 @@ func DateFormat(t time.Time, layout string) (datestring string) {
}
// DateFormat pattern rules.
var DatePatterns = []string{
var datePatterns = []string{
// year
"Y", "2006", // A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"y", "06", //A two digit representation of a year Examples: 99 or 03
@ -103,14 +103,14 @@ var DatePatterns = []string{
// Parse Date use PHP time format.
func DateParse(dateString, format string) (time.Time, error) {
replacer := strings.NewReplacer(DatePatterns...)
replacer := strings.NewReplacer(datePatterns...)
format = replacer.Replace(format)
return time.ParseInLocation(format, dateString, time.Local)
}
// Date takes a PHP like date func to Go's time format.
func Date(t time.Time, format string) string {
replacer := strings.NewReplacer(DatePatterns...)
replacer := strings.NewReplacer(datePatterns...)
format = replacer.Replace(format)
return t.Format(format)
}