mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
support data export
This commit is contained in:
@@ -3,7 +3,9 @@ package utils
|
||||
import "time"
|
||||
|
||||
const (
|
||||
unixTimeFormat = "1136239445"
|
||||
longDateTimeFormat = "2006-01-02 15:04:05"
|
||||
longDateTimeWithoutSecondFormat = "2006-01-02 15:04"
|
||||
)
|
||||
|
||||
// FormatToLongDateTime returns a textual representation of the time value formatted by long date time format
|
||||
@@ -11,6 +13,16 @@ func FormatToLongDateTime(t time.Time) string {
|
||||
return t.Format(longDateTimeFormat)
|
||||
}
|
||||
|
||||
// FormatToLongDateTimeWithoutSecond returns a textual representation of the time value formatted by long date time format (no second)
|
||||
func FormatToLongDateTimeWithoutSecond(t time.Time) string {
|
||||
return t.Format(longDateTimeWithoutSecondFormat)
|
||||
}
|
||||
|
||||
// ParseFromUnixTime parses a unix time and returns a golang time struct
|
||||
func ParseFromUnixTime(unixTime int64) time.Time {
|
||||
return time.Unix(unixTime, 0)
|
||||
}
|
||||
|
||||
// ParseFromLongDateTime parses a formatted string in long date time format
|
||||
func ParseFromLongDateTime(t string) (time.Time, error) {
|
||||
return time.Parse(longDateTimeFormat, t)
|
||||
|
||||
Reference in New Issue
Block a user