Skip to content

Commit

Permalink
remove FromSeconds
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Dec 24, 2024
1 parent fd9f964 commit 26beaa4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
11 changes: 0 additions & 11 deletions go/mysql/datetime/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,3 @@ func NewDateTimeFromStd(t time.Time) DateTime {
Time: NewTimeFromStd(t),
}
}

func NewDateTimeFromSeconds(seconds decimal.Decimal) DateTime {
secondsInt64, _ := seconds.Int64()
timeSeconds := secondsInt64 % (24 * 3600)
tt := NewTimeFromSeconds(decimal.NewFromInt(timeSeconds))
d := DateFromDayNumber(int(secondsInt64 / (24 * 3600)))
return DateTime{
Date: d,
Time: tt,
}
}
26 changes: 0 additions & 26 deletions go/mysql/datetime/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,32 +569,6 @@ func TestToSeconds(t *testing.T) {
assert.Equal(t, 63877375780, int(res))
}

func TestFromSeconds(t *testing.T) {
{
tt := NewTimeFromSeconds(decimal.NewFromInt(45020))

assert.EqualValues(t, 12, tt.Hour())
assert.EqualValues(t, 30, tt.Minute())
assert.EqualValues(t, 20, tt.Second())

res := tt.ToSeconds()
assert.Equal(t, 45020, int(res))
}
{
dt := NewDateTimeFromSeconds(decimal.NewFromInt(63877465820))

assert.EqualValues(t, 2024, dt.Date.Year())
assert.EqualValues(t, 3, dt.Date.Month())
assert.EqualValues(t, 12, dt.Date.Day())
assert.EqualValues(t, 12, dt.Time.Hour())
assert.EqualValues(t, 30, dt.Time.Minute())
assert.EqualValues(t, 20, dt.Time.Second())

res := dt.ToSeconds()
assert.Equal(t, 63877465820, int(res))
}
}

func TestToStdTime(t *testing.T) {
testCases := []struct {
year int
Expand Down

0 comments on commit 26beaa4

Please sign in to comment.