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

This commit is contained in:
Mike Schwörer 2025-07-15 14:14:22 +02:00
parent 8ea9b3f79f
commit a29aec8fb5
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
9 changed files with 44 additions and 68 deletions

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.589" const GoextVersion = "0.0.590"
const GoextVersionTimestamp = "2025-07-15T13:46:36+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

@ -142,11 +142,12 @@ 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 {
if t == nil && u == nil { return t.Time().Equal(u.Time())
return true
} }
if t == nil || u == nil {
func (t RFC3339Time) EqualAny(u AnyTime) bool {
if u == nil {
return false return false
} }
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))

View File

@ -142,11 +142,12 @@ 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 {
if t == nil && u == nil { return t.Time().Equal(u.Time())
return true
} }
if t == nil || u == nil {
func (t RFC3339NanoTime) EqualAny(u AnyTime) bool {
if u == nil {
return false 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

@ -136,11 +136,12 @@ 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 {
if t == nil && u == nil { return t.Time().Equal(u.Time())
return true
} }
if t == nil || u == nil {
func (t UnixTime) EqualAny(u AnyTime) bool {
if u == nil {
return false return false
} }
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))

View File

@ -136,11 +136,12 @@ 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 {
if t == nil && u == nil { return t.Time().Equal(u.Time())
return true
} }
if t == nil || u == nil {
func (t UnixMilliTime) EqualAny(u AnyTime) bool {
if u == nil {
return false return false
} }
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))

View File

@ -136,11 +136,12 @@ 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 {
if t == nil && u == nil { return t.Time().Equal(u.Time())
return true
} }
if t == nil || u == nil {
func (t UnixNanoTime) EqualAny(u AnyTime) bool {
if u == nil {
return false return false
} }
return t.Time().Equal(tt(u)) return t.Time().Equal(tt(u))