包装类型支持转为时间类型
This commit is contained in:
16
string.go
16
string.go
@ -950,6 +950,22 @@ func (str String) ToNumberSlice(splitChar ...string) Float64SliceResult {
|
||||
return str.ToFloat64Slice(splitChar...)
|
||||
}
|
||||
|
||||
// ToDuration 转换为时间格式
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 20:31 2023/9/4
|
||||
func (str String) ToDuration(timeUnit time.Duration) DurationResult {
|
||||
int64Val := str.ToInt64()
|
||||
if nil != int64Val.Err {
|
||||
return DurationResult{
|
||||
Value: 0,
|
||||
Err: int64Val.Err,
|
||||
}
|
||||
}
|
||||
return Int(int64Val.Value).ToDuration(timeUnit)
|
||||
}
|
||||
|
||||
// ToStringSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
Reference in New Issue
Block a user