Aktueller Stand - Datumsberechnungen

This commit is contained in:
Tobias Peper 2025-04-12 10:46:22 +02:00
parent 2ccca9e981
commit 574398344a
2 changed files with 18 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { ChartComponent } from './chart/chart.component';
import { RestService } from './rest.service'; import { RestService } from './rest.service';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { endOfMonth, format, startOfMonth, subMonths } from 'date-fns';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -49,6 +50,22 @@ export class AppComponent implements OnInit, OnChanges {
} }
} }
testFunction(): string {
let startThisMonth: Date = subMonths(startOfMonth(new Date()), 1);
let returnValue: string = '';
for (let i = 0; i < 12; i++) {
let endThisMonth: Date = endOfMonth(startThisMonth);
returnValue += ' / ' + format(startThisMonth, 'dd.MM.yyyy HH:mm:ss')
+ ' - ' + format(endThisMonth, 'dd.MM.yyyy HH:mm:ss')
+ ' (' + startThisMonth.getTime() + ' - ' + endThisMonth.getTime() + ')<br>';
startThisMonth = subMonths(startThisMonth, 1);
}
return returnValue;
}
houseId: number | undefined = undefined; houseId: number | undefined = undefined;
duration: number | undefined = undefined; duration: number | undefined = undefined;
startThisMonth: Date = startOfMonth(new Date());
testDate: string = '';
} }