fix: Return date as a string instead of local time
This commit is contained in:
1 parent
64a4814eef
commit
ccc04dd9ee
6 files changed
+87
-28
No files matched your search
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user