From d64bcfbfd8f3c20fc096af1b40260fdc1af01d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 9 Aug 2023 19:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=84=E7=A7=8D=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E8=8E=B7=E5=8F=96time=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- time.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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<白茶清欢>