Skip to content

Commit

Permalink
Support cvt.TimeFormats to add custom time format
Browse files Browse the repository at this point in the history
  • Loading branch information
shockerli committed Nov 28, 2023
1 parent 351d038 commit 761934e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions time.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ func TimeInLocationE(val interface{}, loc *time.Location) (t time.Time, err erro
return t, newErr(val, "time.Time")
}

var timeFormats = []string{
// TimeFormats all supported time formats
// you can add your custom time format
var TimeFormats = []string{
time.RFC3339,
time.RFC1123Z,
time.RFC1123,
Expand Down Expand Up @@ -144,7 +146,7 @@ var timeFormats = []string{
}

func parseDate(s string, loc *time.Location) (t time.Time, err error) {
for _, dateType := range timeFormats {
for _, dateType := range TimeFormats {
if t, err = time.ParseInLocation(dateType, s, loc); err == nil {
return
}
Expand Down

1 comment on commit 761934e

@vercel
Copy link

@vercel vercel bot commented on 761934e Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cvt – ./

cvt-shockerli.vercel.app
cvt-git-master-shockerli.vercel.app
cvt.shockerli.net

Please sign in to comment.