diff --git a/req_competition_fixtures.go b/req_competition_fixtures.go index ac41957..c255da6 100644 --- a/req_competition_fixtures.go +++ b/req_competition_fixtures.go @@ -13,12 +13,28 @@ func (r CompetitionFixturesRequest) Matchday(matchday uint16) CompetitionFixture return r } -// TimeFrame modifies the request to specify a specific time frame. +// TimeFrame modifies the request to specify a specific relative time frame. func (r CompetitionFixturesRequest) TimeFrame(timeframe time.Duration) CompetitionFixturesRequest { r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe)) return r } +// TimeFrameStart modifies the request to specify the beginning of the time frame filter for the returned results. +// +// Only the year, month and day of the Time value will be used for the request. +func (r CompetitionFixturesRequest) TimeFrameStart(date time.Time) CompetitionFixturesRequest { + r.urlValues.Set("timeFrameStart", date.Format(timeFrameLayout)) + return r +} + +// TimeFrameEnd modifies the request to specify the end of the time frame filter for the returned results. +// +// Only the year, month and day of the Time value will be used for the request. +func (r CompetitionFixturesRequest) TimeFrameStart(date time.Time) CompetitionFixturesRequest { + r.urlValues.Set("timeFrameEnd", date.Format(timeFrameLayout)) + return r +} + // Do executes the request. func (r CompetitionFixturesRequest) Do() (s FixtureList, err error) { d, _, err := r.doJson("GET") diff --git a/req_fixtures.go b/req_fixtures.go index b51af64..54eadbd 100644 --- a/req_fixtures.go +++ b/req_fixtures.go @@ -7,12 +7,28 @@ import ( type FixturesRequest struct{ request } -// TimeFrame modifies the request to specify a specific time frame. +// TimeFrame modifies the request to specify a specific relative time frame. func (r FixturesRequest) TimeFrame(timeframe time.Duration) FixturesRequest { r.urlValues.Set("timeFrame", durationToTimeFrame(timeframe)) return r } +// TimeFrameStart modifies the request to specify the beginning of the time frame filter for the returned results. +// +// Only the year, month and day of the Time value will be used for the request. +func (r FixturesRequest) TimeFrameStart(date time.Time) FixturesRequest { + r.urlValues.Set("timeFrameStart", date.Format(timeFrameLayout)) + return r +} + +// TimeFrameEnd modifies the request to specify the end of the time frame filter for the returned results. +// +// Only the year, month and day of the Time value will be used for the request. +func (r FixturesRequest) TimeFrameStart(date time.Time) FixturesRequest { + r.urlValues.Set("timeFrameEnd", date.Format(timeFrameLayout)) + return r +} + // League modifies the request to specify a list of leagues by their code. func (r FixturesRequest) League(leagueCodes ...string) FixturesRequest { r.urlValues.Set("league", strings.Join(leagueCodes, ",")) diff --git a/util.go b/util.go index 4b42cae..ebd1739 100644 --- a/util.go +++ b/util.go @@ -8,6 +8,8 @@ import ( const ( day = 24 * time.Hour week = 7 * day + + timeFrameLayout = "2006-01-02" ) func durationToTimeFrame(d time.Duration) (r string) {