From c3f8f5cb68725fec9767537b4d36f5cbabf91c24 Mon Sep 17 00:00:00 2001 From: Noah Mirzakhanian Date: Fri, 13 Dec 2024 08:48:58 -0800 Subject: [PATCH] Traits.SetCreatedAt converts time.Time to Unix timestamp --- traits.go | 2 +- traits_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/traits.go b/traits.go index 0ba815e..a074213 100644 --- a/traits.go +++ b/traits.go @@ -25,7 +25,7 @@ func (t Traits) SetBirthday(date time.Time) Traits { } func (t Traits) SetCreatedAt(date time.Time) Traits { - return t.Set("createdAt", date) + return t.Set("createdAt", date.Unix()) } func (t Traits) SetDescription(desc string) Traits { diff --git a/traits_test.go b/traits_test.go index 13b4a9b..560131c 100644 --- a/traits_test.go +++ b/traits_test.go @@ -8,6 +8,7 @@ import ( func TestTraitsSimple(t *testing.T) { date := time.Now() + dateInUnix := date.Unix() text := "ABC" number := 42 @@ -19,7 +20,7 @@ func TestTraitsSimple(t *testing.T) { "age": {Traits{"age": number}, func(t Traits) { t.SetAge(number) }}, "avatar": {Traits{"avatar": text}, func(t Traits) { t.SetAvatar(text) }}, "birthday": {Traits{"birthday": date}, func(t Traits) { t.SetBirthday(date) }}, - "createdAt": {Traits{"createdAt": date}, func(t Traits) { t.SetCreatedAt(date) }}, + "createdAt": {Traits{"createdAt": dateInUnix}, func(t Traits) { t.SetCreatedAt(date) }}, "description": {Traits{"description": text}, func(t Traits) { t.SetDescription(text) }}, "email": {Traits{"email": text}, func(t Traits) { t.SetEmail(text) }}, "firstName": {Traits{"firstName": text}, func(t Traits) { t.SetFirstName(text) }},