Compare commits

...

2 Commits

Author SHA1 Message Date
a29aec8fb5 v0.0.590 more rfctime equal fixes for chris
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m34s
2025-07-15 14:14:22 +02:00
8ea9b3f79f v0.0.589 improve Equal method of rfctime structs - prevents panic in cmp library
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m48s
2025-07-15 13:46:36 +02:00
11 changed files with 62 additions and 54 deletions

2
go.mod
View File

@@ -38,7 +38,7 @@ require (
github.com/google/uuid v1.5.0 // indirect github.com/google/uuid v1.5.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect

2
go.sum
View File

@@ -132,6 +132,8 @@ github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU= github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.588" const GoextVersion = "0.0.590"
const GoextVersionTimestamp = "2025-07-11T11:50:29+0200" const GoextVersionTimestamp = "2025-07-15T14:14:22+0200"

View File

@@ -10,7 +10,8 @@ type RFCTime interface {
After(u AnyTime) bool After(u AnyTime) bool
Before(u AnyTime) bool Before(u AnyTime) bool
Equal(u AnyTime) bool
EqualAny(u AnyTime) bool
Sub(u AnyTime) time.Duration Sub(u AnyTime) time.Duration
} }
@@ -49,45 +50,15 @@ type AnyTime interface {
} }
type RFCDuration interface { type RFCDuration interface {
Time() time.Time Hours() float64
Serialize() string Minutes() float64
Seconds() float64
UnmarshalJSON(bytes []byte) error Microseconds() int64
MarshalJSON() ([]byte, error) Milliseconds() int64
Nanoseconds() int64
MarshalBinary() ([]byte, error)
UnmarshalBinary(data []byte) error
GobEncode() ([]byte, error)
GobDecode(data []byte) error
MarshalText() ([]byte, error)
UnmarshalText(data []byte) error
After(u AnyTime) bool
Before(u AnyTime) bool
Equal(u AnyTime) bool
IsZero() bool
Date() (year int, month time.Month, day int)
Year() int
Month() time.Month
Day() int
Weekday() time.Weekday
ISOWeek() (year, week int)
Clock() (hour, min, sec int)
Hour() int
Minute() int
Second() int
Nanosecond() int
YearDay() int
Sub(u AnyTime) time.Duration
Unix() int64
UnixMilli() int64
UnixMicro() int64
UnixNano() int64
Format(layout string) string
GoString() string
String() string String() string
Duration() time.Duration
} }
func tt(v AnyTime) time.Time { func tt(v AnyTime) time.Time {

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"reflect" "reflect"
"time" "time"
) )
@@ -142,7 +142,14 @@ func (t RFC3339Time) Before(u AnyTime) bool {
return t.Time().Before(tt(u)) return t.Time().Before(tt(u))
} }
func (t RFC3339Time) Equal(u AnyTime) bool { func (t RFC3339Time) Equal(u RFC3339Time) bool {
return t.Time().Equal(u.Time())
}
func (t RFC3339Time) EqualAny(u AnyTime) bool {
if u == nil {
return false
}
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))
} }

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"reflect" "reflect"
"time" "time"
) )
@@ -142,7 +142,14 @@ func (t RFC3339NanoTime) Before(u AnyTime) bool {
return t.Time().Before(tt(u)) return t.Time().Before(tt(u))
} }
func (t RFC3339NanoTime) Equal(u AnyTime) bool { func (t RFC3339NanoTime) Equal(u RFC3339NanoTime) bool {
return t.Time().Equal(u.Time())
}
func (t RFC3339NanoTime) EqualAny(u AnyTime) bool {
if u == nil {
return false
}
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))
} }

View File

@@ -41,7 +41,7 @@ func TestRoundtrip(t *testing.T) {
tst.AssertEqual(t, string(jstr1), string(jstr2)) tst.AssertEqual(t, string(jstr1), string(jstr2))
if !w1.Value.Equal(&w2.Value) { if !w1.Value.EqualAny(&w2.Value) {
t.Errorf("time differs") t.Errorf("time differs")
} }

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/timeext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/timeext"
"reflect" "reflect"
"time" "time"
) )

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"reflect" "reflect"
"strconv" "strconv"
"time" "time"
@@ -136,7 +136,14 @@ func (t UnixTime) Before(u AnyTime) bool {
return t.Time().Before(tt(u)) return t.Time().Before(tt(u))
} }
func (t UnixTime) Equal(u AnyTime) bool { func (t UnixTime) Equal(u UnixTime) bool {
return t.Time().Equal(u.Time())
}
func (t UnixTime) EqualAny(u AnyTime) bool {
if u == nil {
return false
}
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))
} }

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"reflect" "reflect"
"strconv" "strconv"
"time" "time"
@@ -136,7 +136,14 @@ func (t UnixMilliTime) Before(u AnyTime) bool {
return t.Time().Before(tt(u)) return t.Time().Before(tt(u))
} }
func (t UnixMilliTime) Equal(u AnyTime) bool { func (t UnixMilliTime) Equal(u UnixMilliTime) bool {
return t.Time().Equal(u.Time())
}
func (t UnixMilliTime) EqualAny(u AnyTime) bool {
if u == nil {
return false
}
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))
} }

View File

@@ -4,11 +4,11 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
"reflect" "reflect"
"strconv" "strconv"
"time" "time"
@@ -136,7 +136,14 @@ func (t UnixNanoTime) Before(u AnyTime) bool {
return t.Time().Before(tt(u)) return t.Time().Before(tt(u))
} }
func (t UnixNanoTime) Equal(u AnyTime) bool { func (t UnixNanoTime) Equal(u UnixNanoTime) bool {
return t.Time().Equal(u.Time())
}
func (t UnixNanoTime) EqualAny(u AnyTime) bool {
if u == nil {
return false
}
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))
} }