aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Azure/go-autorest/autorest/date
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Azure/go-autorest/autorest/date')
-rw-r--r--vendor/github.com/Azure/go-autorest/autorest/date/date.go82
-rw-r--r--vendor/github.com/Azure/go-autorest/autorest/date/time.go89
-rw-r--r--vendor/github.com/Azure/go-autorest/autorest/date/timerfc1123.go86
-rw-r--r--vendor/github.com/Azure/go-autorest/autorest/date/utility.go11
4 files changed, 0 insertions, 268 deletions
diff --git a/vendor/github.com/Azure/go-autorest/autorest/date/date.go b/vendor/github.com/Azure/go-autorest/autorest/date/date.go
deleted file mode 100644
index 80ca60e9b..000000000
--- a/vendor/github.com/Azure/go-autorest/autorest/date/date.go
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-Package date provides time.Time derivatives that conform to the Swagger.io (https://swagger.io/)
-defined date formats: Date and DateTime. Both types may, in most cases, be used in lieu of
-time.Time types. And both convert to time.Time through a ToTime method.
-*/
-package date
-
-import (
- "fmt"
- "time"
-)
-
-const (
- fullDate = "2006-01-02"
- fullDateJSON = `"2006-01-02"`
- dateFormat = "%04d-%02d-%02d"
- jsonFormat = `"%04d-%02d-%02d"`
-)
-
-// Date defines a type similar to time.Time but assumes a layout of RFC3339 full-date (i.e.,
-// 2006-01-02).
-type Date struct {
- time.Time
-}
-
-// ParseDate create a new Date from the passed string.
-func ParseDate(date string) (d Date, err error) {
- return parseDate(date, fullDate)
-}
-
-func parseDate(date string, format string) (Date, error) {
- d, err := time.Parse(format, date)
- return Date{Time: d}, err
-}
-
-// MarshalBinary preserves the Date as a byte array conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d Date) MarshalBinary() ([]byte, error) {
- return d.MarshalText()
-}
-
-// UnmarshalBinary reconstitutes a Date saved as a byte array conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d *Date) UnmarshalBinary(data []byte) error {
- return d.UnmarshalText(data)
-}
-
-// MarshalJSON preserves the Date as a JSON string conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d Date) MarshalJSON() (json []byte, err error) {
- return []byte(fmt.Sprintf(jsonFormat, d.Year(), d.Month(), d.Day())), nil
-}
-
-// UnmarshalJSON reconstitutes the Date from a JSON string conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d *Date) UnmarshalJSON(data []byte) (err error) {
- d.Time, err = time.Parse(fullDateJSON, string(data))
- return err
-}
-
-// MarshalText preserves the Date as a byte array conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d Date) MarshalText() (text []byte, err error) {
- return []byte(fmt.Sprintf(dateFormat, d.Year(), d.Month(), d.Day())), nil
-}
-
-// UnmarshalText reconstitutes a Date saved as a byte array conforming to RFC3339 full-date (i.e.,
-// 2006-01-02).
-func (d *Date) UnmarshalText(data []byte) (err error) {
- d.Time, err = time.Parse(fullDate, string(data))
- return err
-}
-
-// String returns the Date formatted as an RFC3339 full-date string (i.e., 2006-01-02).
-func (d Date) String() string {
- return fmt.Sprintf(dateFormat, d.Year(), d.Month(), d.Day())
-}
-
-// ToTime returns a Date as a time.Time
-func (d Date) ToTime() time.Time {
- return d.Time
-}
diff --git a/vendor/github.com/Azure/go-autorest/autorest/date/time.go b/vendor/github.com/Azure/go-autorest/autorest/date/time.go
deleted file mode 100644
index c1af62963..000000000
--- a/vendor/github.com/Azure/go-autorest/autorest/date/time.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package date
-
-import (
- "regexp"
- "time"
-)
-
-// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases.
-const (
- azureUtcFormatJSON = `"2006-01-02T15:04:05.999999999"`
- azureUtcFormat = "2006-01-02T15:04:05.999999999"
- rfc3339JSON = `"` + time.RFC3339Nano + `"`
- rfc3339 = time.RFC3339Nano
- tzOffsetRegex = `(Z|z|\+|-)(\d+:\d+)*"*$`
-)
-
-// Time defines a type similar to time.Time but assumes a layout of RFC3339 date-time (i.e.,
-// 2006-01-02T15:04:05Z).
-type Time struct {
- time.Time
-}
-
-// MarshalBinary preserves the Time as a byte array conforming to RFC3339 date-time (i.e.,
-// 2006-01-02T15:04:05Z).
-func (t Time) MarshalBinary() ([]byte, error) {
- return t.Time.MarshalText()
-}
-
-// UnmarshalBinary reconstitutes a Time saved as a byte array conforming to RFC3339 date-time
-// (i.e., 2006-01-02T15:04:05Z).
-func (t *Time) UnmarshalBinary(data []byte) error {
- return t.UnmarshalText(data)
-}
-
-// MarshalJSON preserves the Time as a JSON string conforming to RFC3339 date-time (i.e.,
-// 2006-01-02T15:04:05Z).
-func (t Time) MarshalJSON() (json []byte, err error) {
- return t.Time.MarshalJSON()
-}
-
-// UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC3339 date-time
-// (i.e., 2006-01-02T15:04:05Z).
-func (t *Time) UnmarshalJSON(data []byte) (err error) {
- timeFormat := azureUtcFormatJSON
- match, err := regexp.Match(tzOffsetRegex, data)
- if err != nil {
- return err
- } else if match {
- timeFormat = rfc3339JSON
- }
- t.Time, err = ParseTime(timeFormat, string(data))
- return err
-}
-
-// MarshalText preserves the Time as a byte array conforming to RFC3339 date-time (i.e.,
-// 2006-01-02T15:04:05Z).
-func (t Time) MarshalText() (text []byte, err error) {
- return t.Time.MarshalText()
-}
-
-// UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC3339 date-time
-// (i.e., 2006-01-02T15:04:05Z).
-func (t *Time) UnmarshalText(data []byte) (err error) {
- timeFormat := azureUtcFormat
- match, err := regexp.Match(tzOffsetRegex, data)
- if err != nil {
- return err
- } else if match {
- timeFormat = rfc3339
- }
- t.Time, err = ParseTime(timeFormat, string(data))
- return err
-}
-
-// String returns the Time formatted as an RFC3339 date-time string (i.e.,
-// 2006-01-02T15:04:05Z).
-func (t Time) String() string {
- // Note: time.Time.String does not return an RFC3339 compliant string, time.Time.MarshalText does.
- b, err := t.MarshalText()
- if err != nil {
- return ""
- }
- return string(b)
-}
-
-// ToTime returns a Time as a time.Time
-func (t Time) ToTime() time.Time {
- return t.Time
-}
diff --git a/vendor/github.com/Azure/go-autorest/autorest/date/timerfc1123.go b/vendor/github.com/Azure/go-autorest/autorest/date/timerfc1123.go
deleted file mode 100644
index 11995fb9f..000000000
--- a/vendor/github.com/Azure/go-autorest/autorest/date/timerfc1123.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package date
-
-import (
- "errors"
- "time"
-)
-
-const (
- rfc1123JSON = `"` + time.RFC1123 + `"`
- rfc1123 = time.RFC1123
-)
-
-// TimeRFC1123 defines a type similar to time.Time but assumes a layout of RFC1123 date-time (i.e.,
-// Mon, 02 Jan 2006 15:04:05 MST).
-type TimeRFC1123 struct {
- time.Time
-}
-
-// UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC1123 date-time
-// (i.e., Mon, 02 Jan 2006 15:04:05 MST).
-func (t *TimeRFC1123) UnmarshalJSON(data []byte) (err error) {
- t.Time, err = ParseTime(rfc1123JSON, string(data))
- if err != nil {
- return err
- }
- return nil
-}
-
-// MarshalJSON preserves the Time as a JSON string conforming to RFC1123 date-time (i.e.,
-// Mon, 02 Jan 2006 15:04:05 MST).
-func (t TimeRFC1123) MarshalJSON() ([]byte, error) {
- if y := t.Year(); y < 0 || y >= 10000 {
- return nil, errors.New("Time.MarshalJSON: year outside of range [0,9999]")
- }
- b := []byte(t.Format(rfc1123JSON))
- return b, nil
-}
-
-// MarshalText preserves the Time as a byte array conforming to RFC1123 date-time (i.e.,
-// Mon, 02 Jan 2006 15:04:05 MST).
-func (t TimeRFC1123) MarshalText() ([]byte, error) {
- if y := t.Year(); y < 0 || y >= 10000 {
- return nil, errors.New("Time.MarshalText: year outside of range [0,9999]")
- }
-
- b := []byte(t.Format(rfc1123))
- return b, nil
-}
-
-// UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC1123 date-time
-// (i.e., Mon, 02 Jan 2006 15:04:05 MST).
-func (t *TimeRFC1123) UnmarshalText(data []byte) (err error) {
- t.Time, err = ParseTime(rfc1123, string(data))
- if err != nil {
- return err
- }
- return nil
-}
-
-// MarshalBinary preserves the Time as a byte array conforming to RFC1123 date-time (i.e.,
-// Mon, 02 Jan 2006 15:04:05 MST).
-func (t TimeRFC1123) MarshalBinary() ([]byte, error) {
- return t.MarshalText()
-}
-
-// UnmarshalBinary reconstitutes a Time saved as a byte array conforming to RFC1123 date-time
-// (i.e., Mon, 02 Jan 2006 15:04:05 MST).
-func (t *TimeRFC1123) UnmarshalBinary(data []byte) error {
- return t.UnmarshalText(data)
-}
-
-// ToTime returns a Time as a time.Time
-func (t TimeRFC1123) ToTime() time.Time {
- return t.Time
-}
-
-// String returns the Time formatted as an RFC1123 date-time string (i.e.,
-// Mon, 02 Jan 2006 15:04:05 MST).
-func (t TimeRFC1123) String() string {
- // Note: time.Time.String does not return an RFC1123 compliant string, time.Time.MarshalText does.
- b, err := t.MarshalText()
- if err != nil {
- return ""
- }
- return string(b)
-}
diff --git a/vendor/github.com/Azure/go-autorest/autorest/date/utility.go b/vendor/github.com/Azure/go-autorest/autorest/date/utility.go
deleted file mode 100644
index 207b1a240..000000000
--- a/vendor/github.com/Azure/go-autorest/autorest/date/utility.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package date
-
-import (
- "strings"
- "time"
-)
-
-// ParseTime to parse Time string to specified format.
-func ParseTime(format string, t string) (d time.Time, err error) {
- return time.Parse(format, strings.ToUpper(t))
-}