diff --git a/time.go b/time.go index 48d807f..c0a42f1 100644 --- a/time.go +++ b/time.go @@ -24,6 +24,46 @@ func OwnTime(inputTime time.Time) *Time { } } +// OwnTimeFromSecond 从秒获取实例 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:47 2023/8/9 +func OwnTimeFromSecond(second int64) *Time { + t := time.UnixMilli(second * 1000) + return OwnTime(t) +} + +// OwnTimeFromMilli 从ms获取实例 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:56 2023/8/9 +func OwnTimeFromMilli(milli int64) *Time { + t := time.UnixMilli(milli) + return OwnTime(t) +} + +// OwnTimeFromMicro 从微秒获取实例 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:00 2023/8/9 +func OwnTimeFromMicro(micro int64) *Time { + t := time.UnixMicro(micro) + return OwnTime(t) +} + +// OwnTimeFromNano 从纳秒获取实例 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:00 2023/8/9 +func OwnTimeFromNano(nano int64) *Time { + t := time.Unix(nano/1e9, nano%1e9) + return OwnTime(t) +} + // Time 时间类型 // // Author : go_developer@163.com<白茶清欢>