Skip to content

Commit b525e68

Browse files
dri42David Ribeiro
andauthored
feat(scw): add function TimePtr() (#524)
Co-authored-by: David Ribeiro <[email protected]>
1 parent 648e470 commit b525e68

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

scw/convert.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ func TimeDurationPtr(v time.Duration) *time.Duration {
161161
return &v
162162
}
163163

164+
// TimePtr returns a pointer to the Time value passed in.
165+
func TimePtr(v time.Time) *time.Time {
166+
return &v
167+
}
168+
164169
// SizePtr returns a pointer to the Size value passed in.
165170
func SizePtr(v Size) *Size {
166171
return &v

scw/convert_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var (
1818
testFloat32 float32 = 46
1919
testFloat64 float64 = 47
2020
testDuration time.Duration = 48
21+
testTime time.Time = time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC)
2122
testSize Size = 3 * GB
2223
)
2324

@@ -169,6 +170,14 @@ func TestDurationPtr(t *testing.T) {
169170
testhelpers.Equals(t, testDuration, *pointer)
170171
}
171172

173+
func TestTimePtr(t *testing.T) {
174+
pointer := TimePtr(testTime)
175+
176+
// value to pointer value
177+
testhelpers.Assert(t, pointer != nil, "Pointer should have value")
178+
testhelpers.Equals(t, testTime, *pointer)
179+
}
180+
172181
func TestSizePtr(t *testing.T) {
173182
pointer := SizePtr(testSize)
174183

0 commit comments

Comments
 (0)