From aae4112b32e97ab0c9032f91658af90fdec20072 Mon Sep 17 00:00:00 2001
From: dtapps
Date: Sat, 17 Feb 2024 15:37:55 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20`ToDateFormatTime`=20?=
=?UTF-8?q?=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 2 +-
README.md | 6 ++---
gotime_test.go | 63 ++++++++++++++++++++++++++------------------------
today.go | 5 ++++
version.go | 2 +-
5 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2ee9f26..0f2a114 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,4 @@
.idea
.vscode
.log
-gomod.sh
\ No newline at end of file
+go_mod.sh
\ No newline at end of file
diff --git a/README.md b/README.md
index 0b24b79..8051baa 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
📦 Golang 时间
@@ -12,8 +12,8 @@
#### 安装
-```go
-go get -v -u go.dtapp.net/gotime
+```shell
+go get -v -u go.dtapp.net/gotime@v1.0.7
```
#### 使用
diff --git a/gotime_test.go b/gotime_test.go
index 5665f08..36a7164 100644
--- a/gotime_test.go
+++ b/gotime_test.go
@@ -5,36 +5,39 @@ import (
)
func TestTime(t *testing.T) {
- t.Log("今天此刻:", Current().Now())
- t.Log("测试", Current().SetFormat("20060102150405"))
- t.Log("今天此刻格式化:", Current().Format())
- t.Log("今天此刻日期:", Current().ToDateFormat())
- t.Log("今天此刻时间:", Current().ToTimeFormat())
- t.Log("今天此刻时间戳:", Current().Timestamp())
- t.Log("今天此刻时间戳:", Current().TimestampWithSecond())
- t.Log("今天毫秒级时间戳:", Current().TimestampWithMillisecond())
- t.Log("今天微秒级时间戳:", Current().TimestampWithMicrosecond())
- t.Log("今天纳秒级时间戳:", Current().TimestampWithNanosecond())
-
- t.Log("昨天此刻:", Yesterday().Now())
- t.Log("昨天此刻格式化:", Yesterday().Format())
- t.Log("昨天此刻日期:", Yesterday().ToDateFormat())
- t.Log("昨天此刻时间:", Yesterday().ToTimeFormat())
- t.Log("昨天此刻时间戳:", Yesterday().Timestamp())
- t.Log("昨天此刻时间戳:", Yesterday().TimestampWithSecond())
- t.Log("昨天毫秒级时间戳:", Yesterday().TimestampWithMillisecond())
- t.Log("昨天微秒级时间戳:", Yesterday().TimestampWithMicrosecond())
- t.Log("昨天纳秒级时间戳:", Yesterday().TimestampWithNanosecond())
-
- t.Log("明天此刻:", Tomorrow().Now())
- t.Log("明天此刻格式化:", Tomorrow().Format())
- t.Log("明天此刻日期:", Tomorrow().ToDateFormat())
- t.Log("明天此刻时间:", Tomorrow().ToTimeFormat())
- t.Log("明天此刻时间戳:", Tomorrow().Timestamp())
- t.Log("明天此刻时间戳:", Tomorrow().TimestampWithSecond())
- t.Log("明天毫秒级时间戳:", Tomorrow().TimestampWithMillisecond())
- t.Log("明天微秒级时间戳:", Tomorrow().TimestampWithMicrosecond())
- t.Log("明天纳秒级时间戳:", Tomorrow().TimestampWithNanosecond())
+ t.Log("今天此刻 Now:", Current().Now())
+ t.Log("测试 SetFormat", Current().SetFormat("20060102150405"))
+ t.Log("今天此刻格式化 Format:", Current().Format())
+ t.Log("今天此刻日期 ToDateFormat:", Current().ToDateFormat())
+ t.Log("今天此刻日期 ToDateFormatTime:", Current().ToDateFormatTime())
+ t.Log("今天此刻时间 ToTimeFormat:", Current().ToTimeFormat())
+ t.Log("今天此刻时间戳 Timestamp:", Current().Timestamp())
+ t.Log("今天此刻时间戳 TimestampWithSecond:", Current().TimestampWithSecond())
+ t.Log("今天毫秒级时间戳 TimestampWithMillisecond:", Current().TimestampWithMillisecond())
+ t.Log("今天微秒级时间戳 TimestampWithMicrosecond:", Current().TimestampWithMicrosecond())
+ t.Log("今天纳秒级时间戳 TimestampWithNanosecond:", Current().TimestampWithNanosecond())
+
+ t.Log("昨天此刻 Now:", Yesterday().Now())
+ t.Log("昨天此刻格式化 Format:", Yesterday().Format())
+ t.Log("昨天此刻日期 ToDateFormat:", Yesterday().ToDateFormat())
+ t.Log("昨天此刻日期 ToDateFormatTime:", Yesterday().ToDateFormatTime())
+ t.Log("昨天此刻时间 ToTimeFormat:", Yesterday().ToTimeFormat())
+ t.Log("昨天此刻时间戳 Timestamp:", Yesterday().Timestamp())
+ t.Log("昨天此刻时间戳 TimestampWithSecond:", Yesterday().TimestampWithSecond())
+ t.Log("昨天毫秒级时间戳 TimestampWithMillisecond:", Yesterday().TimestampWithMillisecond())
+ t.Log("昨天微秒级时间戳 TimestampWithMicrosecond:", Yesterday().TimestampWithMicrosecond())
+ t.Log("昨天纳秒级时间戳 TimestampWithNanosecond:", Yesterday().TimestampWithNanosecond())
+
+ t.Log("明天此刻 Now:", Tomorrow().Now())
+ t.Log("明天此刻格式化 Format:", Tomorrow().Format())
+ t.Log("明天此刻日期 ToDateFormat:", Tomorrow().ToDateFormat())
+ t.Log("明天此刻日期 ToDateFormatTime:", Tomorrow().ToDateFormatTime())
+ t.Log("明天此刻时间 ToTimeFormat:", Tomorrow().ToTimeFormat())
+ t.Log("明天此刻时间戳 Timestamp:", Tomorrow().Timestamp())
+ t.Log("明天此刻时间戳 TimestampWithSecond:", Tomorrow().TimestampWithSecond())
+ t.Log("明天毫秒级时间戳 TimestampWithMillisecond:", Tomorrow().TimestampWithMillisecond())
+ t.Log("明天微秒级时间戳 TimestampWithMicrosecond:", Tomorrow().TimestampWithMicrosecond())
+ t.Log("明天纳秒级时间戳 TimestampWithNanosecond:", Tomorrow().TimestampWithNanosecond())
t.Log("本世纪开始时间:", Current().StartOfCentury().Format())
t.Log("本世纪结束时间:", Current().EndOfCentury().Format())
diff --git a/today.go b/today.go
index e5b7421..0bec6c0 100644
--- a/today.go
+++ b/today.go
@@ -96,6 +96,11 @@ func (p Pro) ToDateFormat() string {
return p.Time.Format(DateFormat)
}
+// ToDateFormatTime 今天此刻日期
+func (p Pro) ToDateFormatTime() time.Time {
+ return SetCurrentParse(p.Time.Format(DateFormat)).Time
+}
+
// ToTimeFormat 今天此刻时间
func (p Pro) ToTimeFormat() string {
return p.Time.Format(TimeFormat)
diff --git a/version.go b/version.go
index cd36b9b..7ca4e42 100644
--- a/version.go
+++ b/version.go
@@ -1,3 +1,3 @@
package gotime
-const Version = "1.0.6"
+const Version = "1.0.7"