Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func fansiteUnixToDate(ts int64) string {
if ts <= 0 {
return ""
}
return time.Unix(ts, 0).UTC().Format("2006-01-02")
return time.Unix(ts, 0).In(berlinLocation).Format("2006-01-02")
}

// fansiteDeathReason computes a human-readable death reason sentence for the
Expand Down
37 changes: 37 additions & 0 deletions src/TibiaCharactersCharacter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"reflect"
"strings"
"testing"
"time"

"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
Expand All @@ -25,6 +26,7 @@ func TestFansiteUnixConversions(t *testing.T) {
assert.Equal(t, "", fansiteUnixToDate(0))
assert.Equal(t, "", fansiteUnixToDate(-1))
assert.Equal(t, "2021-12-24", fansiteUnixToDate(1640339536))
assert.Equal(t, "2026-10-20", fansiteUnixToDate(time.Date(2026, time.October, 19, 22, 0, 0, 0, time.UTC).Unix()))
}

func TestFansiteCharacterJSONOptionalFields(t *testing.T) {
Expand Down Expand Up @@ -222,6 +224,41 @@ func TestFansiteCharacterJSONFixtures(t *testing.T) {
}
}

func TestCharacterWillicusHouseDates(t *testing.T) {
expected := []Houses{
{Name: "Alai Flats, Flat 05", Town: "Thais", Paid: "2026-10-25", HouseID: 10305},
{Name: "Alai Flats, Flat 04", Town: "Thais", Paid: "2026-10-22", HouseID: 10304},
{Name: "Alai Flats, Flat 02", Town: "Thais", Paid: "2026-11-11", HouseID: 10302},
}

for _, extension := range []string{"html", "json"} {
t.Run(extension, func(t *testing.T) {
data, err := static.TestFiles.ReadFile("testdata/characters/Willicus." + extension)
if err != nil {
t.Fatal(err)
}

response, err := TibiaCharactersCharacterImpl(string(data), "")
if err != nil {
t.Fatal(err)
}

assert.Equal(t, "Willicus", response.Character.CharacterInfo.Name)
assert.Equal(t, expected, response.Character.CharacterInfo.Houses)

if extension == "json" {
var raw fansiteAPICharacterResponse
if err := json.Unmarshal(data, &raw); err != nil {
t.Fatal(err)
}
for i, house := range raw.CharacterAdminInformation.Houses {
assert.Equal(t, expected[i].Paid, time.Unix(house.PaidUntil, 0).UTC().Format("2006-01-02"))
}
}
})
}
}

func TestCharacterTrollefar(t *testing.T) {
testCases := []struct {
name string
Expand Down
Loading
Loading