From a800f731dd6685b2d505b08342e9bb27952cb423 Mon Sep 17 00:00:00 2001 From: jroam Date: Mon, 22 Apr 2019 13:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=98=9F=E6=9C=9F=E5=80=BC=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/os/gtime/gtime_format.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/g/os/gtime/gtime_format.go b/g/os/gtime/gtime_format.go index ac84b3315..ba391974c 100644 --- a/g/os/gtime/gtime_format.go +++ b/g/os/gtime/gtime_format.go @@ -10,6 +10,7 @@ import ( "bytes" "github.com/gogf/gf/g/text/gregex" "github.com/gogf/gf/g/text/gstr" + "strconv" "strings" ) @@ -135,7 +136,7 @@ func (t *Time) Format(format string) string { case 'u': buffer.WriteString(strings.Replace(result, "=u=.", "", -1)) case 'w': - buffer.WriteString(weekstosint(result)) + buffer.WriteString(strconv.Itoa(int(t.Weekday()))) default: buffer.WriteString(result) } @@ -152,19 +153,3 @@ func (t *Time) Format(format string) string { func (t *Time) Layout(layout string) string { return t.Time.Format(layout) } - -// 将字母的星期数字转为数字:0为星期天 6为星期六 -func weekstosint(week string) string { - - weeks := map[string]string{ - "Monday": "1", - "Tuesday": "2", - "Wednesday": "3", - "Thursday": "4", - "Friday": "5", - "Saturday ": "6", - "Sunday": "0", - } - - return weeks[week] -}