From be01fcc7d399be635ca8a295ab86ed743f463b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Tue, 3 May 2022 11:13:28 +0800 Subject: [PATCH] update --- .gitignore | 3 +- go.mod | 2 +- go.sum | 4 +- http.go | 2 +- vendor/github.com/dtapps/gostring/.gitignore | 8 - vendor/github.com/dtapps/gostring/LICENSE | 21 --- vendor/github.com/dtapps/gostring/README.md | 25 --- vendor/github.com/dtapps/gostring/gostring.go | 151 ------------------ vendor/github.com/dtapps/gotime/.gitignore | 6 - vendor/github.com/dtapps/gotime/LICENSE | 21 --- vendor/github.com/dtapps/gotime/README.md | 25 --- vendor/github.com/dtapps/gotime/Tomorrow.go | 15 -- vendor/github.com/dtapps/gotime/app.go | 105 ------------ vendor/github.com/dtapps/gotime/compare.go | 65 -------- vendor/github.com/dtapps/gotime/differ.go | 69 -------- vendor/github.com/dtapps/gotime/errors.go | 8 - vendor/github.com/dtapps/gotime/location.go | 14 -- vendor/github.com/dtapps/gotime/start_end.go | 124 -------------- vendor/github.com/dtapps/gotime/today.go | 112 ------------- vendor/github.com/dtapps/gotime/yesterday.go | 17 -- vendor/modules.txt | 6 - 21 files changed, 6 insertions(+), 797 deletions(-) delete mode 100644 vendor/github.com/dtapps/gostring/.gitignore delete mode 100644 vendor/github.com/dtapps/gostring/LICENSE delete mode 100644 vendor/github.com/dtapps/gostring/README.md delete mode 100644 vendor/github.com/dtapps/gostring/gostring.go delete mode 100644 vendor/github.com/dtapps/gotime/.gitignore delete mode 100644 vendor/github.com/dtapps/gotime/LICENSE delete mode 100644 vendor/github.com/dtapps/gotime/README.md delete mode 100644 vendor/github.com/dtapps/gotime/Tomorrow.go delete mode 100644 vendor/github.com/dtapps/gotime/app.go delete mode 100644 vendor/github.com/dtapps/gotime/compare.go delete mode 100644 vendor/github.com/dtapps/gotime/differ.go delete mode 100644 vendor/github.com/dtapps/gotime/errors.go delete mode 100644 vendor/github.com/dtapps/gotime/location.go delete mode 100644 vendor/github.com/dtapps/gotime/start_end.go delete mode 100644 vendor/github.com/dtapps/gotime/today.go delete mode 100644 vendor/github.com/dtapps/gotime/yesterday.go delete mode 100644 vendor/modules.txt diff --git a/.gitignore b/.gitignore index 4106571..c316f13 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ .vscode *.log *_test.go -gomod.sh \ No newline at end of file +gomod.sh +/vendor/ diff --git a/go.mod b/go.mod index fd79fbd..b09fa6c 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,5 @@ go 1.18 require ( github.com/dtapps/gostring v1.0.1 - github.com/dtapps/gotime v1.0.0 + github.com/dtapps/gotime v1.0.1 ) diff --git a/go.sum b/go.sum index 82ae19f..8a8e914 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ github.com/dtapps/gostring v1.0.1 h1:J04kndQ08LOqb+H41s8PbMEgNtpheV9iTTl7DSPIZVk= github.com/dtapps/gostring v1.0.1/go.mod h1:BYYnZHrmwpFXkLpd9rQyV5YcChovVreacfcjyMKEwoU= -github.com/dtapps/gotime v1.0.0 h1:VqmkEeKZOJMF7BePotcVvcCJgsIc9TB+OJlysxpDoBk= -github.com/dtapps/gotime v1.0.0/go.mod h1:lbp8pG/8aV3O+t7IuAjasL2WLBsZqLZG6Uw6KqSnox8= +github.com/dtapps/gotime v1.0.1 h1:rO44sQ8tFKUxXrxP7clAOTNS/bwhr/QB9+VwFHPsNH8= +github.com/dtapps/gotime v1.0.1/go.mod h1:lbp8pG/8aV3O+t7IuAjasL2WLBsZqLZG6Uw6KqSnox8= diff --git a/http.go b/http.go index 942f0bb..b97c322 100644 --- a/http.go +++ b/http.go @@ -15,7 +15,7 @@ import ( "time" ) -const Version = "1.0.13" +const Version = "1.0.14" // Response 返回内容 type Response struct { diff --git a/vendor/github.com/dtapps/gostring/.gitignore b/vendor/github.com/dtapps/gostring/.gitignore deleted file mode 100644 index 34509e3..0000000 --- a/vendor/github.com/dtapps/gostring/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.env -.git -.svn -.idea -.vscode -*.log -gitmod.sh -*_test.go \ No newline at end of file diff --git a/vendor/github.com/dtapps/gostring/LICENSE b/vendor/github.com/dtapps/gostring/LICENSE deleted file mode 100644 index a0d0e5b..0000000 --- a/vendor/github.com/dtapps/gostring/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 茂名聚合科技有限公司 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/dtapps/gostring/README.md b/vendor/github.com/dtapps/gostring/README.md deleted file mode 100644 index d8b7032..0000000 --- a/vendor/github.com/dtapps/gostring/README.md +++ /dev/null @@ -1,25 +0,0 @@ -

-Golang String -

- -📦 Golang 字符串组件 - -[comment]: <> (go) -[![godoc](https://pkg.go.dev/badge/github.com/dtapps/gostring?status.svg)](https://pkg.go.dev/github.com/dtapps/gostring) -[![goproxy.cn](https://goproxy.cn/stats/github.com/dtapps/gostring/badges/download-count.svg)](https://goproxy.cn/stats/github.com/dtapps/gostring) -[![goreportcard.com](https://goreportcard.com/badge/github.com/dtapps/gostring)](https://goreportcard.com/report/github.com/dtapps/gostring) -[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/github.com%2Fdtapps%2Fgostring) - -#### 安装使用 - -```go -go get -v -u github.com/dtapps/gostring -``` - -#### 导入 - -```go -import ( - "github.com/dtapps/gostring" -) -``` \ No newline at end of file diff --git a/vendor/github.com/dtapps/gostring/gostring.go b/vendor/github.com/dtapps/gostring/gostring.go deleted file mode 100644 index 587dea1..0000000 --- a/vendor/github.com/dtapps/gostring/gostring.go +++ /dev/null @@ -1,151 +0,0 @@ -package gostring - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/hex" - "fmt" - "strconv" - "strings" - "unicode/utf8" -) - -const Version = "1.0.1" - -// ToString 转换成string -func ToString(value interface{}) string { - if value == nil { - return "" - } - return fmt.Sprint(value) -} - -// ToFloat64 string到float64 -func ToFloat64(s string) float64 { - i, _ := strconv.ParseFloat(s, 64) - return i -} - -// ToInt string到int -func ToInt(s string) int { - i, _ := strconv.Atoi(s) - return i -} - -// ToInt64 string到int64 -func ToInt64(s string) int64 { - i, err := strconv.ParseInt(s, 10, 64) - if err == nil { - return i - } - return int64(ToFloat64(s)) -} - -// ToUint string到uint64 -func ToUint(s string) uint { - i, err := strconv.ParseUint(s, 10, 64) - if err == nil { - return uint(i) - } - return 0 -} - -// ToUint64 string到uint64 -func ToUint64(s string) uint64 { - i, err := strconv.ParseUint(s, 10, 64) - if err == nil { - return i - } - return 0 -} - -// Replace 字符串替换 -func Replace(str, old, new string) string { - return strings.Replace(str, old, new, -1) -} - -func HmacSha256Hex(key, strToSign string) string { - hasHer := hmac.New(sha256.New, []byte(key)) - hasHer.Write([]byte(strToSign)) - return hex.EncodeToString(hasHer.Sum(nil)) -} - -// Space 去除空格 -func Space(str string) string { - return strings.Replace(str, " ", "", -1) -} - -// LineBreak 去除换行符 -func LineBreak(str string) string { - return strings.Replace(str, "\n", "", -1) -} - -// SpaceAndLineBreak 去除空格和去除换行符 -func SpaceAndLineBreak(str string) string { - return LineBreak(Space(str)) -} - -// TrimLastChar 删除字符串中的最后一个 -func TrimLastChar(s string) string { - r, size := utf8.DecodeLastRuneInString(s) - if r == utf8.RuneError && (size == 0 || size == 1) { - size = 0 - } - return s[:len(s)-size] -} - -// Split 字符串分隔 -func Split(s string, sep string) []string { - return strings.Split(s, sep) -} - -// Contains 判断字符串是否包含某个字符 -func Contains(s, substr string) bool { - return strings.Contains(s, substr) -} - -func NumericalToString(value interface{}) (string, bool) { - var val string - - switch value.(type) { - default: - return "0", false - case int: - intVal, _ := value.(int) - val = strconv.FormatInt(int64(intVal), 10) - case int8: - intVal, _ := value.(int8) - val = strconv.FormatInt(int64(intVal), 10) - case int16: - intVal, _ := value.(int16) - val = strconv.FormatInt(int64(intVal), 10) - case int32: - intVal, _ := value.(int32) - val = strconv.FormatInt(int64(intVal), 10) - case int64: - intVal, _ := value.(int64) - val = strconv.FormatInt(int64(intVal), 10) - case uint: - intVal, _ := value.(uint) - val = strconv.FormatUint(uint64(intVal), 10) - case uint8: - intVal, _ := value.(uint8) - val = strconv.FormatUint(uint64(intVal), 10) - case uint16: - intVal, _ := value.(uint16) - val = strconv.FormatUint(uint64(intVal), 10) - case uint32: - intVal, _ := value.(uint32) - val = strconv.FormatUint(uint64(intVal), 10) - case uint64: - intVal, _ := value.(uint64) - val = strconv.FormatUint(intVal, 10) - case float32: - floatVal, _ := value.(float32) - val = strconv.FormatFloat(float64(floatVal), 'f', -1, 32) - case float64: - floatVal, _ := value.(float64) - val = strconv.FormatFloat(floatVal, 'f', -1, 64) - } - return val, true -} diff --git a/vendor/github.com/dtapps/gotime/.gitignore b/vendor/github.com/dtapps/gotime/.gitignore deleted file mode 100644 index 88685d9..0000000 --- a/vendor/github.com/dtapps/gotime/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.env -.git -.svn -.idea -.vscode -.log diff --git a/vendor/github.com/dtapps/gotime/LICENSE b/vendor/github.com/dtapps/gotime/LICENSE deleted file mode 100644 index a0d0e5b..0000000 --- a/vendor/github.com/dtapps/gotime/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 茂名聚合科技有限公司 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/dtapps/gotime/README.md b/vendor/github.com/dtapps/gotime/README.md deleted file mode 100644 index bcbaa9a..0000000 --- a/vendor/github.com/dtapps/gotime/README.md +++ /dev/null @@ -1,25 +0,0 @@ -

-Golang Time -

- -📦 Golang 时间组件 - -[comment]: <> (go) -[![godoc](https://pkg.go.dev/badge/github.com/dtapps/gotime?status.svg)](https://pkg.go.dev/github.com/dtapps/gotime) -[![goproxy.cn](https://goproxy.cn/stats/github.com/dtapps/gotime/badges/download-count.svg)](https://goproxy.cn/stats/github.com/dtapps/gotime) -[![goreportcard.com](https://goreportcard.com/badge/github.com/dtapps/gotime)](https://goreportcard.com/report/github.com/dtapps/gotime) -[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/github.com%2Fdtapps%2Fgotime) - -#### 安装使用 - -```go -go get -v -u github.com/dtapps/gotime -``` - -#### 导入 - -```go -import ( - "github.com/dtapps/gotime" -) -``` \ No newline at end of file diff --git a/vendor/github.com/dtapps/gotime/Tomorrow.go b/vendor/github.com/dtapps/gotime/Tomorrow.go deleted file mode 100644 index e91268f..0000000 --- a/vendor/github.com/dtapps/gotime/Tomorrow.go +++ /dev/null @@ -1,15 +0,0 @@ -package gotime - -import "time" - -// Tomorrow 明天 -func Tomorrow() Pro { - p := NewPro() - location, err := time.LoadLocation("Asia/Shanghai") - if err != nil { - p.Time = time.Now().Add(time.Hour*8).AddDate(0, 0, +1) - } else { - p.Time = time.Now().In(location).AddDate(0, 0, +1) - } - return p -} diff --git a/vendor/github.com/dtapps/gotime/app.go b/vendor/github.com/dtapps/gotime/app.go deleted file mode 100644 index 3bd7dfe..0000000 --- a/vendor/github.com/dtapps/gotime/app.go +++ /dev/null @@ -1,105 +0,0 @@ -package gotime - -import ( - "fmt" - "time" -) - -// 时间格式化常量 -const ( - RFC3339Format = time.RFC3339 - Iso8601Format = "2006-01-02T15:04:05-07:00" - CookieFormat = "Monday, 02-Jan-2006 15:04:05 MST" - RFC1036Format = "Mon, 02 Jan 06 15:04:05 -0700" - RFC7231Format = "Mon, 02 Jan 2006 15:04:05 GMT" - DayDateTimeFormat = "Mon, Jan 2, 2006 3:04 PM" - DateTimeFormat = "2006-01-02 15:04:05" - DateFormat = "2006-01-02" - TimeFormat = "15:04:05" - ShortDateTimeFormat = "20060102150405" - ShortDateFormat = "20060102" - ShortTimeFormat = "150405" -) - -// Pro 结构体 -type Pro struct { - Time time.Time - loc *time.Location - Error error -} - -// NewPro 初始化结构体 -func NewPro() Pro { - return Pro{ - Time: time.Now(), - } -} - -// BeforeSeconds 获取n秒前的时间 -func (p Pro) BeforeSeconds(seconds int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("-%ds", seconds)) - p.Time = p.Time.Add(st) - return p -} - -// AfterSeconds 获取n秒后的时间 -func (p Pro) AfterSeconds(seconds int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("+%ds", seconds)) - p.Time = p.Time.Add(st) - return p -} - -// BeforeMinute 获取n分钟前的时间 -func (p Pro) BeforeMinute(seconds int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("-%dm", seconds)) - p.Time = p.Time.Add(st) - return p -} - -// AfterMinute 获取n分钟后的时间 -func (p Pro) AfterMinute(seconds int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("+%dm", seconds)) - p.Time = p.Time.Add(st) - return p -} - -// BeforeHour 获取n小时前的时间 -func (p Pro) BeforeHour(hour int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("-%dh", hour)) - p.Time = p.Time.Add(st) - return p -} - -// AfterHour 获取n小时后的时间 -func (p Pro) AfterHour(hour int) Pro { - st, _ := time.ParseDuration(fmt.Sprintf("+%dh", hour)) - p.Time = p.Time.Add(st) - return p -} - -// BeforeDay 获取n天前的时间 -func (p Pro) BeforeDay(day int) Pro { - p.Time = p.Time.AddDate(0, 0, -day) - return p -} - -// AfterDay 获取n天后的时间 -func (p Pro) AfterDay(day int) Pro { - p.Time = p.Time.AddDate(0, 0, day) - return p -} - -// SetFormat 格式化 -func (p Pro) SetFormat(layout string) string { - return p.Time.Format(layout) -} - -// Month 获取当前月 -func (p Pro) Month() int { - return p.MonthOfYear() -} - -// MonthOfYear 获取本年的第几月 -func (p Pro) MonthOfYear() int { - return int(p.Time.In(p.loc).Month()) -} diff --git a/vendor/github.com/dtapps/gotime/compare.go b/vendor/github.com/dtapps/gotime/compare.go deleted file mode 100644 index bc89964..0000000 --- a/vendor/github.com/dtapps/gotime/compare.go +++ /dev/null @@ -1,65 +0,0 @@ -package gotime - -import "time" - -// Gt 是否大于 -func (p Pro) Gt(t2 time.Time) bool { - return p.Time.After(t2) -} - -// Lt 是否小于 -func (p Pro) Lt(t2 time.Time) bool { - return p.Time.Before(t2) -} - -// Eq 是否等于 -func (p Pro) Eq(t2 time.Time) bool { - return p.Time.Equal(t2) -} - -// Ne 是否不等于 -func (p Pro) Ne(t2 time.Time) bool { - return !p.Eq(t2) -} - -// Gte 是否大于等于 -func (p Pro) Gte(t2 time.Time) bool { - return p.Gt(t2) || p.Eq(t2) -} - -// Lte 是否小于等于 -func (p Pro) Lte(t2 time.Time) bool { - return p.Lt(t2) || p.Eq(t2) -} - -// Between 是否在两个时间之间(不包括这两个时间) -func (p Pro) Between(start time.Time, end time.Time) bool { - if p.Gt(start) && p.Lt(end) { - return true - } - return false -} - -// BetweenIncludedStart 是否在两个时间之间(包括开始时间) -func (p Pro) BetweenIncludedStart(start time.Time, end time.Time) bool { - if p.Gte(start) && p.Lt(end) { - return true - } - return false -} - -// BetweenIncludedEnd 是否在两个时间之间(包括结束时间) -func (p Pro) BetweenIncludedEnd(start time.Time, end time.Time) bool { - if p.Gt(start) && p.Lte(end) { - return true - } - return false -} - -// BetweenIncludedBoth 是否在两个时间之间(包括这两个时间) -func (p Pro) BetweenIncludedBoth(start time.Time, end time.Time) bool { - if p.Gte(start) && p.Lte(end) { - return true - } - return false -} diff --git a/vendor/github.com/dtapps/gotime/differ.go b/vendor/github.com/dtapps/gotime/differ.go deleted file mode 100644 index 0ad3033..0000000 --- a/vendor/github.com/dtapps/gotime/differ.go +++ /dev/null @@ -1,69 +0,0 @@ -package gotime - -import "time" - -// DiffInHour 相差多少小时 -func (p Pro) DiffInHour(t2 time.Time) (hour int64) { - t2.Before(p.Time) - diff := p.Time.Unix() - t2.Unix() - hour = diff / 3600 - return hour -} - -// DiffInHourWithAbs 相差多少小时(绝对值) -func (p Pro) DiffInHourWithAbs(t2 time.Time) (hour int64) { - p.Time.Before(t2) - diff := t2.Unix() - p.Time.Unix() - hour = diff / 3600 - if hour > 0 { - return hour - } - t2.Before(p.Time) - diff = p.Time.Unix() - t2.Unix() - hour = diff / 3600 - return hour -} - -// DiffInMinutes 相差多少分钟 -func (p Pro) DiffInMinutes(t2 time.Time) (hour int64) { - t2.Before(p.Time) - diff := p.Time.Unix() - t2.Unix() - hour = diff / 60 - return hour -} - -// DiffInMinutesWithAbs 相差多少分钟(绝对值) -func (p Pro) DiffInMinutesWithAbs(t2 time.Time) (hour int64) { - p.Time.Before(t2) - diff := t2.Unix() - p.Time.Unix() - hour = diff / 60 - if hour > 0 { - return hour - } - t2.Before(p.Time) - diff = p.Time.Unix() - t2.Unix() - hour = diff / 60 - return hour -} - -// DiffInSecond 相差多少秒 -func (p Pro) DiffInSecond(t2 time.Time) (hour int64) { - t2.Before(p.Time) - diff := p.Time.Unix() - t2.Unix() - hour = diff - return hour -} - -// DiffInSecondWithAbs 相差多少秒(绝对值) -func (p Pro) DiffInSecondWithAbs(t2 time.Time) (hour int64) { - p.Time.Before(t2) - diff := t2.Unix() - p.Time.Unix() - hour = diff - if hour > 0 { - return hour - } - t2.Before(p.Time) - diff = p.Time.Unix() - t2.Unix() - hour = diff - return hour -} diff --git a/vendor/github.com/dtapps/gotime/errors.go b/vendor/github.com/dtapps/gotime/errors.go deleted file mode 100644 index 2f69622..0000000 --- a/vendor/github.com/dtapps/gotime/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package gotime - -import "fmt" - -// invalidTimezoneError 无效的时区错误 -var invalidTimezoneError = func(timezone string) error { - return fmt.Errorf("invalid timezone %q, please see the file %q for all valid timezones", timezone, "$GOROOT/lib/time/zoneinfo.zip") -} diff --git a/vendor/github.com/dtapps/gotime/location.go b/vendor/github.com/dtapps/gotime/location.go deleted file mode 100644 index 1b664ab..0000000 --- a/vendor/github.com/dtapps/gotime/location.go +++ /dev/null @@ -1,14 +0,0 @@ -package gotime - -import ( - "time" -) - -// 通过时区获取 Location 实例 -func getLocationByTimezone(timezone string) (*time.Location, error) { - loc, err := time.LoadLocation(timezone) - if err != nil { - err = invalidTimezoneError(timezone) - } - return loc, err -} diff --git a/vendor/github.com/dtapps/gotime/start_end.go b/vendor/github.com/dtapps/gotime/start_end.go deleted file mode 100644 index 5afb4f5..0000000 --- a/vendor/github.com/dtapps/gotime/start_end.go +++ /dev/null @@ -1,124 +0,0 @@ -package gotime - -import "time" - -// 数字常量 -const ( - YearsPerMillennium = 1000 // 每千年1000年 - YearsPerCentury = 100 // 每世纪100年 - YearsPerDecade = 10 // 每十年10年 - QuartersPerYear = 4 // 每年4季度 - MonthsPerYear = 12 // 每年12月 - MonthsPerQuarter = 3 // 每季度3月 - WeeksPerNormalYear = 52 // 每常规年52周 - weeksPerLongYear = 53 // 每长年53周 - WeeksPerMonth = 4 // 每月4周 - DaysPerLeapYear = 366 // 每闰年366天 - DaysPerNormalYear = 365 // 每常规年365天 - DaysPerWeek = 7 // 每周7天 - HoursPerWeek = 168 // 每周168小时 - HoursPerDay = 24 // 每天24小时 - MinutesPerDay = 1440 // 每天1440分钟 - MinutesPerHour = 60 // 每小时60分钟 - SecondsPerWeek = 604800 // 每周604800秒 - SecondsPerDay = 86400 // 每天86400秒 - SecondsPerHour = 3600 // 每小时3600秒 - SecondsPerMinute = 60 // 每分钟60秒 - MillisecondsPerSecond = 1000 // 每秒1000毫秒 - MicrosecondsPerMillisecond = 1000 // 每毫秒1000微秒 - MicrosecondsPerSecond = 1000000 // 每秒1000000微秒 -) - -// StartOfCentury 本世纪开始时间 -func (p Pro) StartOfCentury() Pro { - p.Time = time.Date(p.Time.Year()/YearsPerCentury*YearsPerCentury, 1, 1, 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfCentury 本世纪结束时间 -func (p Pro) EndOfCentury() Pro { - p.Time = time.Date(p.Time.Year()/YearsPerCentury*YearsPerCentury+99, 12, 31, 23, 59, 59, 999999999, p.Time.Location()) - return p -} - -// StartOfDecade 本年代开始时间 -func (p Pro) StartOfDecade() Pro { - p.Time = time.Date(p.Time.Year()/YearsPerDecade*YearsPerDecade, 1, 1, 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfDecade 本年代结束时间 -func (p Pro) EndOfDecade() Pro { - p.Time = time.Date(p.Time.Year()/YearsPerDecade*YearsPerDecade+9, 12, 31, 23, 59, 59, 999999999, p.Time.Location()) - return p -} - -// StartOfYear 本年开始时间 -func (p Pro) StartOfYear() Pro { - p.Time = time.Date(p.Time.Year(), 1, 1, 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfYear 本年结束时间 -func (p Pro) EndOfYear() Pro { - p.Time = time.Date(p.Time.Year(), 12, 31, 23, 59, 59, 999999999, p.Time.Location()) - return p -} - -// Quarter 获取当前季度 -func (p Pro) Quarter() (quarter int) { - switch { - case p.Time.Month() >= 10: - quarter = 4 - case p.Time.Month() >= 7: - quarter = 3 - case p.Time.Month() >= 4: - quarter = 2 - case p.Time.Month() >= 1: - quarter = 1 - } - return -} - -// StartOfQuarter 本季度开始时间 -func (p Pro) StartOfQuarter() Pro { - p.Time = time.Date(p.Time.Year(), time.Month(3*p.Quarter()-2), 1, 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfQuarter 本季度结束时间 -func (p Pro) EndOfQuarter() Pro { - quarter, day := p.Quarter(), 30 - switch quarter { - case 1, 4: - day = 31 - case 2, 3: - day = 30 - } - p.Time = time.Date(p.Time.Year(), time.Month(3*quarter), day, 23, 59, 59, 999999999, p.Time.Location()) - return p -} - -// StartOfMonth 本月开始时间 -func (p Pro) StartOfMonth() Pro { - p.Time = time.Date(p.Time.Year(), time.Month(p.Month()), 1, 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfMonth 本月结束时间 -func (p Pro) EndOfMonth() Pro { - p.Time = time.Date(p.Time.Year(), time.Month(p.Month()), 1, 23, 59, 59, 999999999, p.Time.Location()) - return p -} - -// StartOfDay 本日开始时间 -func (p Pro) StartOfDay() Pro { - p.Time = time.Date(p.Time.Year(), p.Time.Month(), p.Time.Day(), 0, 0, 0, 0, p.Time.Location()) - return p -} - -// EndOfDay 本日结束时间 -func (p Pro) EndOfDay() Pro { - p.Time = time.Date(p.Time.Year(), p.Time.Month(), p.Time.Day(), 23, 59, 59, 0, p.Time.Location()) - return p -} diff --git a/vendor/github.com/dtapps/gotime/today.go b/vendor/github.com/dtapps/gotime/today.go deleted file mode 100644 index f19f505..0000000 --- a/vendor/github.com/dtapps/gotime/today.go +++ /dev/null @@ -1,112 +0,0 @@ -package gotime - -import ( - "log" - "strconv" - "strings" - "time" -) - -// Current 获取当前的时间 -func Current() Pro { - p := NewPro() - p.loc, p.Error = time.LoadLocation("Asia/Shanghai") - if p.Error != nil { - // Docker部署golang应用时时区问题 https://www.ddhigh.com/2018/03/01/golang-docker-timezone.html - log.Printf("【gotime】时区错误:%v\n", p.Error) - p.Time = time.Now().Add(time.Hour * 8) - } else { - p.Time = time.Now().In(p.loc) - } - return p -} - -// SetCurrent 设置当前的时间 -func SetCurrent(sTime time.Time) Pro { - p := NewPro() - p.Time = sTime - return p -} - -// SetCurrentParse 设置当前的时间 -func SetCurrentParse(str string) Pro { - - p := NewPro() - - p.loc, p.Error = time.LoadLocation("Asia/Shanghai") - - layout := DateTimeFormat - if str == "" || str == "0" || str == "0000-00-00 00:00:00" || str == "0000-00-00" || str == "00:00:00" { - return p - } - if len(str) == 10 && strings.Count(str, "-") == 2 { - layout = DateFormat - } - if strings.Index(str, "T") == 10 { - layout = RFC3339Format - } - if _, err := strconv.ParseInt(str, 10, 64); err == nil { - switch len(str) { - case 8: - layout = ShortDateFormat - case 14: - layout = ShortDateTimeFormat - } - } - location, _ := time.ParseInLocation(layout, str, p.loc) - - p.Time = location - return p -} - -// SetCurrentUnix 设置当前的时间 Unix时间戳 -func SetCurrentUnix(ts int64) Pro { - p := NewPro() - p.Time = time.Unix(ts, 0) - return p -} - -// Now 今天此刻 -func (p Pro) Now() time.Time { - return p.Time -} - -// Format 今天此刻格式化 -func (p Pro) Format() string { - return p.Time.Format(DateTimeFormat) -} - -// ToDateFormat 今天此刻日期 -func (p Pro) ToDateFormat() string { - return p.Time.Format(DateFormat) -} - -// ToTimeFormat 今天此刻时间 -func (p Pro) ToTimeFormat() string { - return p.Time.Format(TimeFormat) -} - -// Timestamp 今天此刻时间戳 -func (p Pro) Timestamp() int64 { - return p.Time.Unix() -} - -// TimestampWithSecond 今天此刻时间戳 -func (p Pro) TimestampWithSecond() int64 { - return p.Time.Unix() -} - -// TimestampWithMillisecond 今天毫秒级时间戳 -func (p Pro) TimestampWithMillisecond() int64 { - return p.Time.UnixNano() / int64(time.Millisecond) -} - -// TimestampWithMicrosecond 今天微秒级时间戳 -func (p Pro) TimestampWithMicrosecond() int64 { - return p.Time.UnixNano() / int64(time.Microsecond) -} - -// TimestampWithNanosecond 今天纳秒级时间戳 -func (p Pro) TimestampWithNanosecond() int64 { - return p.Time.UnixNano() -} diff --git a/vendor/github.com/dtapps/gotime/yesterday.go b/vendor/github.com/dtapps/gotime/yesterday.go deleted file mode 100644 index be1cd6c..0000000 --- a/vendor/github.com/dtapps/gotime/yesterday.go +++ /dev/null @@ -1,17 +0,0 @@ -package gotime - -import ( - "time" -) - -// Yesterday 昨天 -func Yesterday() Pro { - p := NewPro() - location, err := time.LoadLocation("Asia/Shanghai") - if err != nil { - p.Time = time.Now().Add(time.Hour*8).AddDate(0, 0, -1) - } else { - p.Time = time.Now().In(location).AddDate(0, 0, -1) - } - return p -} diff --git a/vendor/modules.txt b/vendor/modules.txt deleted file mode 100644 index a4697f3..0000000 --- a/vendor/modules.txt +++ /dev/null @@ -1,6 +0,0 @@ -# github.com/dtapps/gostring v1.0.1 -## explicit -github.com/dtapps/gostring -# github.com/dtapps/gotime v1.0.0 -## explicit; go 1.18 -github.com/dtapps/gotime