mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 14:26:58 +00:00
@@ -127,7 +127,73 @@ export default {
|
||||
this.setEnd(end);
|
||||
this.range.start = start;
|
||||
this.range.end = end;
|
||||
this.generatePeriods()
|
||||
return false;
|
||||
},
|
||||
generatePeriods: function () {
|
||||
this.periods = [];
|
||||
// create periods.
|
||||
let today;
|
||||
let end;
|
||||
|
||||
today = new Date(this.range.start);
|
||||
|
||||
// previous month
|
||||
firstDayOfMonth = new Date(today.getFullYear(), today.getMonth()-1, 1);
|
||||
lastDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 0);
|
||||
this.periods.push(
|
||||
{
|
||||
start: firstDayOfMonth.toDateString(),
|
||||
end: lastDayOfMonth.toDateString(),
|
||||
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
|
||||
}
|
||||
);
|
||||
|
||||
// this month
|
||||
firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0);
|
||||
this.periods.push(
|
||||
{
|
||||
start: firstDayOfMonth.toDateString(),
|
||||
end: lastDayOfMonth.toDateString(),
|
||||
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
|
||||
}
|
||||
);
|
||||
|
||||
// next month
|
||||
let firstDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 1);
|
||||
let lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+2, 0);
|
||||
this.periods.push(
|
||||
{
|
||||
start: firstDayOfMonth.toDateString(),
|
||||
end: lastDayOfMonth.toDateString(),
|
||||
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
|
||||
}
|
||||
);
|
||||
|
||||
// last 7 days
|
||||
today = new Date;
|
||||
end = new Date;
|
||||
end.setDate(end.getDate() - 7);
|
||||
this.periods.push(
|
||||
{
|
||||
start: end.toDateString(),
|
||||
end: today.toDateString(),
|
||||
title: this.$t('firefly.last_seven_days')
|
||||
}
|
||||
);
|
||||
|
||||
// last 30 days:
|
||||
end.setDate(end.getDate() - 23);
|
||||
this.periods.push(
|
||||
{
|
||||
start: end.toDateString(),
|
||||
end: today.toDateString(),
|
||||
title: this.$t('firefly.last_thirty_days')
|
||||
}
|
||||
);
|
||||
// last 30 days
|
||||
// everything
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -149,31 +215,8 @@ export default {
|
||||
}
|
||||
this.range.start = new Date(this.start);
|
||||
this.range.end = new Date(this.end);
|
||||
this.periods = [];
|
||||
// create periods.
|
||||
// last 7 days
|
||||
let today = new Date;
|
||||
let end = new Date;
|
||||
end.setDate(end.getDate() - 7);
|
||||
this.periods.push(
|
||||
{
|
||||
start: end.toDateString(),
|
||||
end: today.toDateString(),
|
||||
title: this.$t('firefly.last_seven_days')
|
||||
}
|
||||
);
|
||||
this.generatePeriods();
|
||||
|
||||
// last 30 days:
|
||||
end.setDate(end.getDate() - 23);
|
||||
this.periods.push(
|
||||
{
|
||||
start: end.toDateString(),
|
||||
end: today.toDateString(),
|
||||
title: this.$t('firefly.last_thirty_days')
|
||||
}
|
||||
);
|
||||
// last 30 days
|
||||
// everything
|
||||
},
|
||||
range: function (value) {
|
||||
//console.log('User updated range');
|
||||
|
@@ -92,13 +92,18 @@ export default {
|
||||
},
|
||||
timeStr: {
|
||||
get() {
|
||||
// console.log('getTimeStr: ' + this.localTime);
|
||||
if (this.localTime instanceof Date && !isNaN(this.localTime)) {
|
||||
return ('0' + this.localTime.getHours()).slice(-2) + ':' + ('0' + this.localTime.getMinutes()).slice(-2) + ':' + ('0' + this.localTime.getSeconds()).slice(-2);
|
||||
let localStr = ('0' + this.localTime.getHours()).slice(-2) + ':' + ('0' + this.localTime.getMinutes()).slice(-2) + ':' + ('0' + this.localTime.getSeconds()).slice(-2);
|
||||
// console.log('Time is: ' + localStr);
|
||||
return localStr;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
set(value) {
|
||||
// console.log('Set: ' + value);
|
||||
if ('' === value) {
|
||||
// console.log('Value is empty, set 00:00:00');
|
||||
this.localTime.setHours(0);
|
||||
this.localTime.setMinutes(0);
|
||||
this.localTime.setSeconds(0);
|
||||
@@ -108,9 +113,11 @@ export default {
|
||||
// bit of a hack but meh.
|
||||
let current = new Date(this.localTime.getTime());
|
||||
let parts = value.split(':');
|
||||
current.setHours(parseInt(parts[0]));
|
||||
current.setMinutes(parseInt(parts[1]));
|
||||
current.setSeconds(parseInt(parts[2]));
|
||||
// console.log('Parts are:');
|
||||
// console.log(parts);
|
||||
current.setHours(parseInt(parts[0] ?? 0));
|
||||
current.setMinutes(parseInt(parts[1] ?? 0));
|
||||
current.setSeconds(parseInt(parts[2] ?? 0));
|
||||
this.localTime = current;
|
||||
this.$emit('set-time', {time: this.localTime});
|
||||
}
|
||||
|
Reference in New Issue
Block a user