mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
fix issue in G&j char format
This commit is contained in:
parent
dc82ce395a
commit
c56c77d3a1
@ -9,7 +9,8 @@ package gtime
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/gogf/gf/g/text/gregex"
|
||||
"strings"
|
||||
"github.com/gogf/gf/g/text/gstr"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -126,8 +127,8 @@ func (t *Time) Format(format string) string {
|
||||
result := t.Time.Format(f)
|
||||
// 有几个转换的符号需要特殊处理
|
||||
switch runes[i] {
|
||||
case 'j': buffer.WriteString(strings.Replace(result, "=j=0", "", -1))
|
||||
case 'G': buffer.WriteString(strings.Replace(result, "=G=0", "", -1))
|
||||
case 'j': buffer.WriteString(gstr.ReplaceByArray(result, []string{"=j=0", "", "=j=", ""}))
|
||||
case 'G': buffer.WriteString(gstr.ReplaceByArray(result, []string{"=G=0", "", "=G=", ""}))
|
||||
case 'u': buffer.WriteString(strings.Replace(result, "=u=.", "", -1))
|
||||
default:
|
||||
buffer.WriteString(result)
|
||||
|
@ -2,34 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/g/database/gredis"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
)
|
||||
|
||||
var (
|
||||
config = gredis.Config{
|
||||
Host : "127.0.0.1",
|
||||
Port : 6379,
|
||||
Db : 1,
|
||||
}
|
||||
"github.com/gogf/gf/g/os/gtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
group := "test"
|
||||
gredis.SetConfig(config, group)
|
||||
|
||||
redis := gredis.Instance(group)
|
||||
defer redis.Close()
|
||||
|
||||
_, err := redis.Do("SET", "k", "v")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
r, err := redis.Do("GET", "k")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(gconv.String(r))
|
||||
|
||||
fmt.Println(gtime.Now().Format(`Y-m-j G:i:su`))
|
||||
}
|
Loading…
Reference in New Issue
Block a user