|
|
@@ -16,6 +16,12 @@ const (
|
|
|
DateFmtNumeric = `20060102`
|
|
|
)
|
|
|
|
|
|
+// 时间日期格式长度
|
|
|
+const (
|
|
|
+ TimeLength = 19
|
|
|
+ DateLength = 10
|
|
|
+)
|
|
|
+
|
|
|
// IsTime 是否时间格式字符串
|
|
|
func IsTime(s string) bool {
|
|
|
if _, err := time.Parse(TimeFmtLong, s); err != nil {
|
|
|
@@ -76,6 +82,12 @@ func StrFmtLocationTime(s, fmt string) (t time.Time, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// StrToLocationDate 字符串转日期
|
|
|
+func StrToLocationDate(s string) (t time.Time, err error) {
|
|
|
+ t, err = time.ParseInLocation(DateFmtLong, s, time.Local)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// IsWeekEnd 日期是否周末
|
|
|
func IsWeekEnd(d time.Weekday) bool {
|
|
|
day := int(d)
|