fix: Return date as a string instead of local time
This commit is contained in:
@@ -73,17 +73,21 @@ func (d Provider) parseResponse(res *req.Response) ([]prayer.Times, error) {
|
||||
return nil, fmt.Errorf("received error: %s", res.String())
|
||||
}
|
||||
|
||||
if len(response.ResultObject.PrayerTimes) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var times []prayer.Times
|
||||
const format = "15:04"
|
||||
now := time.Now()
|
||||
today := time.Now().UTC().Truncate(time.Hour * 24)
|
||||
for _, pt := range response.ResultObject.PrayerTimes {
|
||||
then := pt.Date.UTC().Truncate(time.Hour * 24)
|
||||
if then.Before(now) {
|
||||
then := prayer.Date(pt.Date).Time()
|
||||
if then.Before(today) {
|
||||
continue
|
||||
}
|
||||
|
||||
times = append(times, prayer.Times{
|
||||
Date: then,
|
||||
Date: pt.Date.Format(time.DateOnly),
|
||||
Fajr: pt.Fajr.Format(format),
|
||||
Sunrise: pt.Sunrise.Format(format),
|
||||
Dhuhr: pt.Dhuhr.Format(format),
|
||||
|
||||
@@ -30,6 +30,8 @@ func TestDiyanetAPI_GetByCoords(t *testing.T) {
|
||||
times, err := p.Get(context.Background(), "11104")
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, times)
|
||||
t.Logf("%#+v", times[0])
|
||||
for _, time := range times {
|
||||
t.Log(time)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user