mirror of https://github.com/status-im/fathom.git
Merge branch 'master' into grouped-referrers
This commit is contained in:
commit
e05a6d7f1e
|
@ -42,36 +42,36 @@ class DatePicker extends Component {
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
updateDatesFromPeriod(period) {
|
updateDatesFromPeriod(period) {
|
||||||
let startDate = new Date();
|
let now = new Date();
|
||||||
startDate.setHours(0);
|
let startDate, endDate;
|
||||||
startDate.setMinutes(0);
|
|
||||||
startDate.setSeconds(0);
|
|
||||||
|
|
||||||
let endDate = new Date();
|
|
||||||
endDate.setHours(23);
|
|
||||||
endDate.setMinutes(59);
|
|
||||||
endDate.setSeconds(59);
|
|
||||||
|
|
||||||
switch(period) {
|
switch(period) {
|
||||||
|
case "day":
|
||||||
|
startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||||
|
endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||||
|
break;
|
||||||
|
|
||||||
case "week":
|
case "week":
|
||||||
startDate.setDate(startDate.getDate() - (startDate.getDay() + 6) % 7);
|
startDate = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - (now.getDay() + 6) % 7));
|
||||||
endDate.setDate(startDate.getDate() + 6);
|
endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + 6);
|
||||||
break;
|
break;
|
||||||
case "month":
|
case "month":
|
||||||
startDate.setDate(1);
|
startDate = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||||
endDate.setDate(5); // because every month has date 5... use date-fn here later on
|
endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0);
|
||||||
endDate.setMonth(startDate.getMonth() + 1);
|
|
||||||
endDate.setDate(0);
|
|
||||||
break;
|
break;
|
||||||
case "year":
|
case "year":
|
||||||
startDate.setDate(1);
|
startDate = new Date(now.getFullYear(), 0, 1);
|
||||||
startDate.setMonth(0);
|
endDate = new Date(startDate.getFullYear() + 1, 0, 0);
|
||||||
endDate.setYear(startDate.getFullYear() + 1);
|
break;
|
||||||
endDate.setMonth(0);
|
|
||||||
endDate.setDate(0);
|
case "":
|
||||||
|
default:
|
||||||
|
return; // empty period, don't update state
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startDate.setHours(0, 0, 0);
|
||||||
|
endDate.setHours(23, 59, 59);
|
||||||
this.setDateRange(startDate, endDate, period);
|
this.setDateRange(startDate, endDate, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue