The Reporting features of the Harvest API allow you to set your time period when querying time entries and expenses. To simplify the task of pulling entries for the current or previous week/month the Harvest_Range class contains static methods to return an object preset to the given period. All of these functions take two parameters:
- timeZone – The Time Zone to be used by default the server time zone is used but if your server is in a different time zone then you will want to set this parameter.
- startOfWeek – The day of the week that your work week begins on. The default is set to Sunday (0) but you can pass in 1 if your week starts on Monday.
Harvest_Range set to this week
$range = Harvest_Range::thisWeek( "EST", Harvest_Range::MONDAY );
$range = Harvest_Range::thisWeek();
Harvest_Range set to the previous month
$range = Harvest_Range::lastMonth();
Obtaining time entries logged against a project last week
You can use these preset methods in conjunction with the reporting functions of the Harvest API. For example you could get all the time entries logged for a project during the last week.
$result = $api->getProjectEntries( 652605, new Harvest_Range::lastWeek( "EST" ) );
Comments & Questions
Add Your Comment