summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cast/internal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cast/internal')
-rw-r--r--vendor/github.com/spf13/cast/internal/time.go79
-rw-r--r--vendor/github.com/spf13/cast/internal/timeformattype_string.go27
2 files changed, 0 insertions, 106 deletions
diff --git a/vendor/github.com/spf13/cast/internal/time.go b/vendor/github.com/spf13/cast/internal/time.go
deleted file mode 100644
index 906e9aece..000000000
--- a/vendor/github.com/spf13/cast/internal/time.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package internal
-
-import (
- "fmt"
- "time"
-)
-
-//go:generate stringer -type=TimeFormatType
-
-type TimeFormatType int
-
-const (
- TimeFormatNoTimezone TimeFormatType = iota
- TimeFormatNamedTimezone
- TimeFormatNumericTimezone
- TimeFormatNumericAndNamedTimezone
- TimeFormatTimeOnly
-)
-
-type TimeFormat struct {
- Format string
- Typ TimeFormatType
-}
-
-func (f TimeFormat) HasTimezone() bool {
- // We don't include the formats with only named timezones, see
- // https://github.com/golang/go/issues/19694#issuecomment-289103522
- return f.Typ >= TimeFormatNumericTimezone && f.Typ <= TimeFormatNumericAndNamedTimezone
-}
-
-var TimeFormats = []TimeFormat{
- // Keep common formats at the top.
- {"2006-01-02", TimeFormatNoTimezone},
- {time.RFC3339, TimeFormatNumericTimezone},
- {"2006-01-02T15:04:05", TimeFormatNoTimezone}, // iso8601 without timezone
- {time.RFC1123Z, TimeFormatNumericTimezone},
- {time.RFC1123, TimeFormatNamedTimezone},
- {time.RFC822Z, TimeFormatNumericTimezone},
- {time.RFC822, TimeFormatNamedTimezone},
- {time.RFC850, TimeFormatNamedTimezone},
- {"2006-01-02 15:04:05.999999999 -0700 MST", TimeFormatNumericAndNamedTimezone}, // Time.String()
- {"2006-01-02T15:04:05-0700", TimeFormatNumericTimezone}, // RFC3339 without timezone hh:mm colon
- {"2006-01-02 15:04:05Z0700", TimeFormatNumericTimezone}, // RFC3339 without T or timezone hh:mm colon
- {"2006-01-02 15:04:05", TimeFormatNoTimezone},
- {time.ANSIC, TimeFormatNoTimezone},
- {time.UnixDate, TimeFormatNamedTimezone},
- {time.RubyDate, TimeFormatNumericTimezone},
- {"2006-01-02 15:04:05Z07:00", TimeFormatNumericTimezone},
- {"02 Jan 2006", TimeFormatNoTimezone},
- {"2006-01-02 15:04:05 -07:00", TimeFormatNumericTimezone},
- {"2006-01-02 15:04:05 -0700", TimeFormatNumericTimezone},
- {time.Kitchen, TimeFormatTimeOnly},
- {time.Stamp, TimeFormatTimeOnly},
- {time.StampMilli, TimeFormatTimeOnly},
- {time.StampMicro, TimeFormatTimeOnly},
- {time.StampNano, TimeFormatTimeOnly},
-}
-
-func ParseDateWith(s string, location *time.Location, formats []TimeFormat) (d time.Time, e error) {
- for _, format := range formats {
- if d, e = time.Parse(format.Format, s); e == nil {
-
- // Some time formats have a zone name, but no offset, so it gets
- // put in that zone name (not the default one passed in to us), but
- // without that zone's offset. So set the location manually.
- if format.Typ <= TimeFormatNamedTimezone {
- if location == nil {
- location = time.Local
- }
- year, month, day := d.Date()
- hour, min, sec := d.Clock()
- d = time.Date(year, month, day, hour, min, sec, d.Nanosecond(), location)
- }
-
- return
- }
- }
- return d, fmt.Errorf("unable to parse date: %s", s)
-}
diff --git a/vendor/github.com/spf13/cast/internal/timeformattype_string.go b/vendor/github.com/spf13/cast/internal/timeformattype_string.go
deleted file mode 100644
index 60a29a862..000000000
--- a/vendor/github.com/spf13/cast/internal/timeformattype_string.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Code generated by "stringer -type=TimeFormatType"; DO NOT EDIT.
-
-package internal
-
-import "strconv"
-
-func _() {
- // An "invalid array index" compiler error signifies that the constant values have changed.
- // Re-run the stringer command to generate them again.
- var x [1]struct{}
- _ = x[TimeFormatNoTimezone-0]
- _ = x[TimeFormatNamedTimezone-1]
- _ = x[TimeFormatNumericTimezone-2]
- _ = x[TimeFormatNumericAndNamedTimezone-3]
- _ = x[TimeFormatTimeOnly-4]
-}
-
-const _TimeFormatType_name = "TimeFormatNoTimezoneTimeFormatNamedTimezoneTimeFormatNumericTimezoneTimeFormatNumericAndNamedTimezoneTimeFormatTimeOnly"
-
-var _TimeFormatType_index = [...]uint8{0, 20, 43, 68, 101, 119}
-
-func (i TimeFormatType) String() string {
- if i < 0 || i >= TimeFormatType(len(_TimeFormatType_index)-1) {
- return "TimeFormatType(" + strconv.FormatInt(int64(i), 10) + ")"
- }
- return _TimeFormatType_name[_TimeFormatType_index[i]:_TimeFormatType_index[i+1]]
-}