I have the following switch statement function which is returning entries in an API from a set time date:
entries: {
recent: function(callback) {
return self.request(rest.get, '/timeentries', { startDate: '2016-02-15' }, function(result) {
callback(result);
});
},
This is working fine, I am getting results back from anything post 2016-02-15.
However, I don't want this to be static. I want to be able to pull a date range from when this is run.
I have the following code which returns the current week:
var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay();
var firstDay = new Date(curr.setDate(first)).toUTCString();
firstDay returns the start of the week, which is what I want to put in place of startDate: '2016-02-15'.
Question, how would I put firstDay in here, the following wont work:
entries: {
recent: function(callback) {
var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay();
var firstDay = new Date(curr.setDate(first)).toUTCString();
return self.request(rest.get, '/timeentries', { firstDate }, function(result) {
callback(result);
});
},