nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: go-openapi/strfmt
Pull request #52 (2019-04-08 09:57:22)

Handle JSON null values for DateTime
Signed-off-by: André Bierlein <andre.mt.bierlein@gmail.com>


Patch:
diff --git a/time.go b/time.go
index f550dc4..0ca8010 100644
--- a/time.go
+++ b/time.go
@@ -156,6 +156,9 @@ func (t DateTime) MarshalEasyJSON(w *jwriter.Writer) {
 
 // UnmarshalJSON sets the DateTime from JSON
 func (t *DateTime) UnmarshalJSON(data []byte) error {
+	if string(data) == jsonNull {
+		return nil
+	}
 	l := jlexer.Lexer{Data: data}
 	t.UnmarshalEasyJSON(&l)
 	return l.Error()


Test patch:
diff --git a/time_test.go b/time_test.go
index f0cd47a..6cc47df 100644
--- a/time_test.go
+++ b/time_test.go
@@ -145,6 +145,10 @@ func TestDateTime_UnmarshalJSON(t *testing.T) {
 	// Check lexer failure
 	err = pp.UnmarshalJSON([]byte(`"zorg emperor"`))
 	assert.Error(t, err)
+
+	// Check null case
+	err = pp.UnmarshalJSON([]byte("null"))
+	assert.Nil(t, err)
 }
 
 func esc(v []byte) []byte {
Repository: go-openapi/strfmt
Pull request #54 (2019-04-11 00:31:18)

Issue #53: Added support for parsing ISO8601 timestamps that are in local time.
ISO8601 states that timestamps without their timezone component are timestamps that are in "local" time. This PR adds support for parsing those types of timestamps.


Patch:
diff --git a/time.go b/time.go
index 0ca8010..453c943 100644
--- a/time.go
+++ b/time.go
@@ -56,12 +56,14 @@ const (
 	RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
 	// RFC3339Micro represents a ISO8601 format to micro instead of to nano
 	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"
 	// 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}
+	dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime}
 	rxDateTime      = regexp.MustCompile(DateTimePattern)
 	// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
 	MarshalFormat = RFC3339Millis


Test patch:
diff --git a/time_test.go b/time_test.go
index 6cc47df..ee30fde 100644
--- a/time_test.go
+++ b/time_test.go
@@ -31,6 +31,7 @@ var (
 		time time.Time // its representation in time.Time
 		str  string    // its marshalled representation
 	}{
+		{[]byte("2014-12-15T08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z"},
 		{[]byte("2014-12-15T08:00:00.000Z"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z"},
 		{[]byte("2011-08-18T19:03:37.000000000+01:00"), time.Date(2011, 8, 18, 19, 3, 37, 0, p.Location()), "2011-08-18T19:03:37.000+01:00"},
 		{[]byte("2014-12-15T19:30:20Z"), time.Date(2014, 12, 15, 19, 30, 20, 0, time.UTC), "2014-12-15T19:30:20.000Z"},
Repository: go-openapi/strfmt
Pull request #66 (2020-07-16 20:17:05)

handle time offset without colon
Was using `go-swagger` and was having issues with a server I don't control sending back a time string like `2020-07-16T20:10:54.570+0000`

I was getting an error from `parsing time "2020-07-16T19:13:38.908+0000": extra text: :38.908+0000`

This seems to fix that. Not super familiar with this codebase, just took a jab and added some tests where it felt correct. Let me know if there's any adjustments you'd like to see or concerns. 


Patch:
diff --git a/time.go b/time.go
index 0b2f52d..b673616 100644
--- a/time.go
+++ b/time.go
@@ -55,8 +55,12 @@ func IsDateTime(str string) bool {
 const (
 	// RFC3339Millis represents a ISO8601 format to millis instead of to nanos
 	RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
+	// RFC3339Millis represents a ISO8601 format to millis instead of to nanos
+	RFC3339MillisNoColon = "2006-01-02T15:04:05.000Z0700"
 	// RFC3339Micro represents a ISO8601 format to micro instead of to nano
 	RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
+	// RFC3339Micro represents a ISO8601 format to micro instead of to nano
+	RFC3339MicroNoColon = "2006-01-02T15:04:05.000000Z0700"
 	// 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)
@@ -68,7 +72,7 @@ const (
 )
 
 var (
-	dateTimeFormats = []string{RFC3339Micro, RFC3339Millis, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime}
+	dateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, 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


Test patch:
diff --git a/time_test.go b/time_test.go
index d8bd288..764c6be 100644
--- a/time_test.go
+++ b/time_test.go
@@ -38,6 +38,8 @@ var (
 		{[]byte("2018-01-28T23:54Z"), time.Date(2018, 01, 28, 23, 54, 0, 0, time.UTC), "2018-01-28T23:54:00.000Z"},
 		{[]byte("2014-12-15T08:00:00.000Z"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z"},
 		{[]byte("2011-08-18T19:03:37.000000000+01:00"), time.Date(2011, 8, 18, 19, 3, 37, 0, p.Location()), "2011-08-18T19:03:37.000+01:00"},
+		{[]byte("2011-08-18T19:03:37.000000+0100"), time.Date(2011, 8, 18, 19, 3, 37, 0, p.Location()), "2011-08-18T19:03:37.000+01:00"},
+		{[]byte("2011-08-18T19:03:37.000+0100"), time.Date(2011, 8, 18, 19, 3, 37, 0, p.Location()), "2011-08-18T19:03:37.000+01:00"},
 		{[]byte("2014-12-15T19:30:20Z"), time.Date(2014, 12, 15, 19, 30, 20, 0, time.UTC), "2014-12-15T19:30:20.000Z"},
 		{[]byte("0001-01-01T00:00:00Z"), time.Time{}.UTC(), "0001-01-01T00:00:00.000Z"},
 		{[]byte(""), time.Unix(0, 0).UTC(), "1970-01-01T00:00:00.000Z"},
Repository: go-openapi/strfmt
Pull request #75 (2020-11-17 07:57:38)

Add support for parsing ISO8601 universal sortable date time pattern


Patch:
diff --git a/time.go b/time.go
index 3724eb7..f1b9626 100644
--- a/time.go
+++ b/time.go
@@ -67,14 +67,18 @@ const (
 	ISO8601TimeWithReducedPrecision = "2006-01-02T15:04Z"
 	// ISO8601TimeWithReducedPrecisionLocaltime represents a ISO8601 format with reduced precision and no timezone (dropped seconds + no timezone)
 	ISO8601TimeWithReducedPrecisionLocaltime = "2006-01-02T15:04"
+	// ISO8601TimeUniversalSortableDateTimePattern represents a ISO8601 universal sortable date time pattern.
+	ISO8601TimeUniversalSortableDateTimePattern = "2006-01-02 15:04:05"
 	// 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 (
 	rxDateTime = regexp.MustCompile(DateTimePattern)
+
 	// DateTimeFormats is the collection of formats used by ParseDateTime()
-	DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime}
+	DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime, ISO8601TimeUniversalSortableDateTimePattern}
+
 	// MarshalFormat sets the time resolution format used for marshaling time (set to milliseconds)
 	MarshalFormat = RFC3339Millis
 


Test patch:
diff --git a/time_test.go b/time_test.go
index c7d2ea2..a6d1030 100644
--- a/time_test.go
+++ b/time_test.go
@@ -33,6 +33,7 @@ var (
 		str    string    // its marshalled representation
 		utcStr string    // the marshaled representation as utc
 	}{
+		{[]byte("2014-12-15 08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
 		{[]byte("2014-12-15T08:00:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
 		{[]byte("2014-12-15T08:00"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
 		{[]byte("2014-12-15T08:00Z"), time.Date(2014, 12, 15, 8, 0, 0, 0, time.UTC), "2014-12-15T08:00:00.000Z", "2014-12-15T08:00:00.000Z"},
Repository: go-openapi/strfmt
Pull request #76 (2020-12-30 09:14:10)

Add Equal methods to DateTime and Date
Adds support for for `DateTime.Equal(DateTime)` and `Date.Equal(Date)` that uses time's Equal method.

This would simplify our testing flow a lot as the dependency we use (`github.com go-test/deep`) skips checking time.Time's internal properties (exp, loc, ...) by default.



Patch:
diff --git a/date.go b/date.go
index 15029ff..f0b3109 100644
--- a/date.go
+++ b/date.go
@@ -180,3 +180,8 @@ func (d *Date) UnmarshalBinary(data []byte) error {
 
 	return nil
 }
+
+// Equal checks if two Date instances are equal
+func (d Date) Equal(d2 Date) bool {
+	return time.Time(d).Equal(time.Time(d2))
+}
diff --git a/time.go b/time.go
index f1b9626..425413f 100644
--- a/time.go
+++ b/time.go
@@ -274,3 +274,8 @@ func (t *DateTime) UnmarshalBinary(data []byte) error {
 
 	return nil
 }
+
+// Equal checks if two DateTime instances are equal using time.Time's Equal method
+func (t DateTime) Equal(t2 DateTime) bool {
+	return time.Time(t).Equal(time.Time(t2))
+}


Test patch:
diff --git a/date_test.go b/date_test.go
index 4097e8a..77b00ed 100644
--- a/date_test.go
+++ b/date_test.go
@@ -160,3 +160,15 @@ func TestGobEncodingDate(t *testing.T) {
 	assert.Equal(t, now.Month(), time.Time(result).Month())
 	assert.Equal(t, now.Day(), time.Time(result).Day())
 }
+
+func TestDate_Equal(t *testing.T) {
+	t.Parallel()
+
+	d1 := Date(time.Date(2020, 10, 11, 12, 13, 14, 15, time.UTC))
+	d2 := Date(time.Date(2020, 10, 11, 12, 13, 14, 15, time.UTC))
+	d3 := Date(time.Date(2020, 11, 12, 13, 14, 15, 16, time.UTC))
+
+	assert.True(t, d1.Equal(d1), "Same Date should Equal itself")
+	assert.True(t, d1.Equal(d2), "Date instances should be equal")
+	assert.False(t, d1.Equal(d3), "Date instances should not be equal")
+}
diff --git a/time_test.go b/time_test.go
index a6d1030..e97c3e1 100644
--- a/time_test.go
+++ b/time_test.go
@@ -313,3 +313,13 @@ func TestGobEncodingDateTime(t *testing.T) {
 	assert.Equal(t, now.Minute(), time.Time(result).Minute())
 	assert.Equal(t, now.Second(), time.Time(result).Second())
 }
+
+func TestDateTime_Equal(t *testing.T) {
+	t.Parallel()
+
+	dt1 := DateTime(time.Now())
+	dt2 := DateTime(time.Time(dt1).Add(time.Second))
+
+	assert.True(t, dt1.Equal(dt1), "DateTime instances should be equal")
+	assert.False(t, dt1.Equal(dt2), "DateTime instances should not be equal")
+}
Repository: go-openapi/strfmt
Pull request #140 (2025-01-10 00:44:48)

Revert "use pointer receivers on the IsZero variants for DateTime"
This reverts commit b36a4901fcb51dbf4300a5a6b60b4335440aa208.

Fixes https://github.com/go-openapi/strfmt/issues/139


Patch:
diff --git a/time.go b/time.go
index f08ba4d..2f83187 100644
--- a/time.go
+++ b/time.go
@@ -135,19 +135,13 @@ func (t DateTime) String() string {
 }
 
 // IsZero returns whether the date time is a zero value
-func (t *DateTime) IsZero() bool {
-	if t == nil {
-		return true
-	}
-	return time.Time(*t).IsZero()
+func (t DateTime) IsZero() bool {
+	return time.Time(t).IsZero()
 }
 
 // IsUnixZerom returns whether the date time is equivalent to time.Unix(0, 0).UTC().
-func (t *DateTime) IsUnixZero() bool {
-	if t == nil {
-		return true
-	}
-	return time.Time(*t).Equal(UnixZero)
+func (t DateTime) IsUnixZero() bool {
+	return time.Time(t) == UnixZero
 }
 
 // MarshalText implements the text marshaller interface


Test patch:
diff --git a/time_test.go b/time_test.go
index 2dc4f2f..6f2edd5 100644
--- a/time_test.go
+++ b/time_test.go
@@ -58,15 +58,11 @@ func TestNewDateTime(t *testing.T) {
 func TestIsZero(t *testing.T) {
 	var empty DateTime
 	assert.True(t, empty.IsZero())
-	var nilDt *DateTime
-	assert.True(t, nilDt.IsZero())
-	small := DateTime(time.Unix(100, 5))
-	assert.False(t, small.IsZero())
+	assert.False(t, DateTime(time.Unix(100, 5)).IsZero())
 
 	// time.Unix(0,0) does not produce a true zero value struct,
 	// so this is expected to fail.
-	dt := NewDateTime()
-	assert.False(t, dt.IsZero())
+	assert.False(t, NewDateTime().IsZero())
 }
 
 func TestIsUnixZero(t *testing.T) {
@@ -77,9 +73,7 @@ func TestIsUnixZero(t *testing.T) {
 	estLocation := time.FixedZone("EST", int((-5 * time.Hour).Seconds()))
 	estUnixZero := time.Unix(0, 0).In(estLocation)
 	UnixZero = estUnixZero
-	t.Cleanup(func() { UnixZero = time.Unix(0, 0).UTC() })
-	dtz := DateTime(estUnixZero)
-	assert.True(t, dtz.IsUnixZero())
+	assert.True(t, DateTime(estUnixZero).IsUnixZero())
 }
 
 func TestParseDateTime_errorCases(t *testing.T) {