包装类型支持转为时间类型

This commit is contained in:
2023-09-04 20:35:42 +08:00
parent 2886126ae7
commit faafa8ee2a
3 changed files with 41 additions and 0 deletions

13
int.go
View File

@ -10,6 +10,7 @@ package wrapper
import (
"fmt"
"math"
"time"
)
// Int int类型
@ -19,6 +20,18 @@ import (
// Date : 13:57 2023/5/5
type Int int64
// ToDuration ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:33 2023/9/4
func (i Int) ToDuration(timeUnit time.Duration) DurationResult {
return DurationResult{
Value: time.Duration(i.ToInt64().Value) * timeUnit,
Err: nil,
}
}
// ToInt8 ...
//
// Author : go_developer@163.com<白茶清欢>