提交 e584eb28 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

close date related tasks

上级 5ef701b0
title: month date
desc: 月日
author: zentao
version: "1.0"
fields:
- field: monthday_common
from: base.time.monthday.v1.yaml
use: common
prefix: ""
postfix: "\t"
- field: monthday_with_line
from: base.time.monthday.v1.yaml
use: with_line
prefix: ""
postfix: "\t"
- field: monthday_chinese
from: base.time.monthday.v1.yaml
use: chinese
prefix: ""
postfix: "\t"
- field: date_common
from: base.time.date.v1.yaml
use: common
prefix: ""
postfix: "\t"
- field: date_with_line
from: base.time.date.v1.yaml
use: with_line
prefix: ""
postfix: "\t"
- field: date_chinese
from: base.time.date.v1.yaml
use: chinese
prefix: ""
postfix: "\t"
\ No newline at end of file
......@@ -2,7 +2,6 @@ package gen
import (
"errors"
"fmt"
"github.com/easysoft/zendata/src/model"
commonUtils "github.com/easysoft/zendata/src/utils/common"
constant "github.com/easysoft/zendata/src/utils/const"
......@@ -247,7 +246,14 @@ func GetFieldValStr(field model.DefField, val interface{}) string {
}
case string:
str = val.(string)
fmt.Sprintf(str)
match, _ := regexp.MatchString("%[0-9]*d", field.Format)
if match {
valInt, err := strconv.Atoi(str)
if err == nil {
str, success = stringUtils.FormatStr(field.Format, valInt)
}
}
default:
}
......
title: 日期时间
desc:
author: zentao
version: 1.0
field: date
instances:
- instance: common
note: 普通
prefix:
fields:
- field: year
range: 2020
- field: month_day
from: base.time.monthday.v1.yaml
use: common
prefix: ""
postfix: "\t"
- instance: with_line
note: 下划线
prefix:
fields:
- field: year
range: 2020
postfix: "-"
- field: month_day
from: base.time.monthday.v1.yaml
use: with_line
prefix: ""
postfix: "\t"
- instance: chinese
note: 中文
prefix:
fields:
- field: year
range: 2020
postfix: "年"
- field: month_day
from: base.time.monthday.v1.yaml
use: chinese
prefix: ""
postfix: "\t"
\ No newline at end of file
title: 月日
desc:
author: zentao
version: 1.0
field: monthdate
instances:
- instance: common
note: 普通
prefix:
fields:
- field: month
range: 1{31},2{28},3{31},4{30},5{31},6{30},7{31},8{31},9{30},10{31},11{30},12{31}
format: "%02d"
postfix: ""
- field: day
range: 1-31,1-28,1-31, 1-30,1-31,1-30, 1-31,1-31,1-30, 1-31,1-30,1-31
format: "%02d"
- instance: with_line
note: 下划线分隔
prefix:
fields:
- field: month
range: 1{31},2{28},3{31},4{30},5{31},6{30},7{31},8{31},9{30},10{31},11{30},12{31}
format: "%02d"
postfix: "-"
- field: day
range: 1-31,1-28,1-31, 1-30,1-31,1-30, 1-31,1-31,1-30, 1-31,1-30,1-31
format: "%02d"
- instance: chinese
note: 中文日期
prefix:
fields:
- field: month
range: 1{31},2{28},3{31},4{30},5{31},6{30},7{31},8{31},9{30},10{31},11{30},12{31}
format: "%02d"
postfix: "月"
- field: day
range: 1-31,1-28,1-31, 1-30,1-31,1-30, 1-31,1-31,1-30, 1-31,1-30,1-31
format: "%02d"
postfix: "日"
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册