diff --git a/gen/config.go b/gen/config.go index d7143f4..119bf07 100644 --- a/gen/config.go +++ b/gen/config.go @@ -8,6 +8,7 @@ import ( "time" "github.com/alehechka/json2go/jenshared" + "github.com/alehechka/json2go/utils" ) // Config presents Gen configurations. @@ -65,45 +66,5 @@ func (c *Config) prepareOutputFileName() { } func (c *Config) getTimeFormat() string { - - if len(c.TimeFormat) == 0 { - return time.RFC3339 - } - - switch c.TimeFormat { - case "Layout": - return time.Layout - case "ANSIC": - return time.ANSIC - case "UnixDate": - return time.UnixDate - case "RubyDate": - return time.RubyDate - case "RFC822": - return time.RFC822 - case "RFC822Z": - return time.RFC822Z - case "RFC850": - return time.RFC850 - case "RFC1123": - return time.RFC1123 - case "RFC1123Z": - return time.RFC1123Z - case "RFC3339": - return time.RFC3339 - case "RFC3339Nano": - return time.RFC3339Nano - case "Kitchen": - return time.Kitchen - case "Stamp": - return time.Stamp - case "StampMilli": - return time.StampMilli - case "StampMicro": - return time.StampMicro - case "StampNano": - return time.StampNano - default: - return c.TimeFormat - } + return utils.GetTimeFormat(c.TimeFormat, time.RFC3339) }