[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger * vendor
This commit is contained in:
parent
66843f2237
commit
3270e7a443
350 changed files with 26353 additions and 5552 deletions
90
vendor/github.com/go-openapi/strfmt/time.go
generated
vendored
90
vendor/github.com/go-openapi/strfmt/time.go
generated
vendored
|
@ -4,7 +4,7 @@
|
|||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -16,14 +16,16 @@ package strfmt
|
|||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/bsontype"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -57,12 +59,16 @@ const (
|
|||
RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
|
||||
// ISO8601LocalTime represents a ISO8601 format to ISO8601 in local time (no timezone)
|
||||
ISO8601LocalTime = "2006-01-02T15:04:05"
|
||||
// ISO8601TimeWithReducedPrecision represents a ISO8601 format with reduced precision (dropped secs)
|
||||
ISO8601TimeWithReducedPrecision = "2006-01-02T15:04Z"
|
||||
// ISO8601TimeWithReducedPrecision represents a ISO8601 format with reduced precision and no timezone (dropped seconds + no timezone)
|
||||
ISO8601TimeWithReducedPrecisionLocaltime = "2006-01-02T15:04"
|
||||
// DateTimePattern pattern to match for the date-time format from http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$`
|
||||
)
|
||||
|
||||
var (
|
||||
dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime}
|
||||
dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime}
|
||||
rxDateTime = regexp.MustCompile(DateTimePattern)
|
||||
// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
|
||||
MarshalFormat = RFC3339Millis
|
||||
|
@ -165,26 +171,51 @@ func (t *DateTime) UnmarshalJSON(data []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalBSON renders the DateTime as a BSON document
|
||||
func (t DateTime) MarshalBSON() ([]byte, error) {
|
||||
return bson.Marshal(bson.M{"data": t.String()})
|
||||
return bson.Marshal(bson.M{"data": t})
|
||||
}
|
||||
|
||||
// UnmarshalBSON reads the DateTime from a BSON document
|
||||
func (t *DateTime) UnmarshalBSON(data []byte) error {
|
||||
var m bson.M
|
||||
if err := bson.Unmarshal(data, &m); err != nil {
|
||||
var obj struct {
|
||||
Data DateTime
|
||||
}
|
||||
|
||||
if err := bson.Unmarshal(data, &obj); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if data, ok := m["data"].(string); ok {
|
||||
rd, err := ParseDateTime(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = rd
|
||||
return nil
|
||||
}
|
||||
*t = obj.Data
|
||||
|
||||
return errors.New("couldn't unmarshal bson bytes value as Date")
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBSONValue is an interface implemented by types that can marshal themselves
|
||||
// into a BSON document represented as bytes. The bytes returned must be a valid
|
||||
// BSON document if the error is nil.
|
||||
// Marshals a DateTime as a bsontype.DateTime, an int64 representing
|
||||
// milliseconds since epoch.
|
||||
func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
|
||||
// UnixNano cannot be used, the result of calling UnixNano on the zero
|
||||
// Time is undefined.
|
||||
i64 := time.Time(t).Unix() * 1000
|
||||
buf := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(buf, uint64(i64))
|
||||
|
||||
return bsontype.DateTime, buf, nil
|
||||
}
|
||||
|
||||
// UnmarshalBSONValue is an interface implemented by types that can unmarshal a
|
||||
// BSON value representation of themselves. The BSON bytes and type can be
|
||||
// assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it
|
||||
// wishes to retain the data after returning.
|
||||
func (t *DateTime) UnmarshalBSONValue(tpe bsontype.Type, data []byte) error {
|
||||
i64 := int64(binary.LittleEndian.Uint64(data))
|
||||
// TODO: Use bsonprim.DateTime.Time() method
|
||||
*t = DateTime(time.Unix(i64/1000, i64%1000*1000000))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto copies the receiver and writes its value into out.
|
||||
|
@ -201,3 +232,32 @@ func (t *DateTime) DeepCopy() *DateTime {
|
|||
t.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// GobEncode implements the gob.GobEncoder interface.
|
||||
func (t DateTime) GobEncode() ([]byte, error) {
|
||||
return t.MarshalBinary()
|
||||
}
|
||||
|
||||
// GobDecode implements the gob.GobDecoder interface.
|
||||
func (t *DateTime) GobDecode(data []byte) error {
|
||||
return t.UnmarshalBinary(data)
|
||||
}
|
||||
|
||||
// MarshalBinary implements the encoding.BinaryMarshaler interface.
|
||||
func (t DateTime) MarshalBinary() ([]byte, error) {
|
||||
return time.Time(t).MarshalBinary()
|
||||
}
|
||||
|
||||
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
|
||||
func (t *DateTime) UnmarshalBinary(data []byte) error {
|
||||
var original time.Time
|
||||
|
||||
err := original.UnmarshalBinary(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*t = DateTime(original)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue