@acontplus/ng-components 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,6 +48,7 @@ import * as i2$3 from '@angular/material/input';
|
|
|
48
48
|
import { MatInputModule } from '@angular/material/input';
|
|
49
49
|
import { Datex, SPANISH_LOCALE, DEFAULT_THEME, MATERIAL_THEME, BOOTSTRAP_THEME } from 'datex-ui';
|
|
50
50
|
export { BOOTSTRAP_THEME, DEFAULT_THEME, Datex, MATERIAL_THEME, SPANISH_LOCALE, SPANISH_LOCALE_WITH_TIME } from 'datex-ui';
|
|
51
|
+
import { addDay, monthStart, monthEnd, weekStart, weekEnd } from '@formkit/tempo';
|
|
51
52
|
import { TranslocoService } from '@jsverse/transloco';
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -3367,6 +3368,7 @@ class DateRangePicker {
|
|
|
3367
3368
|
this.stateChanges.next();
|
|
3368
3369
|
}
|
|
3369
3370
|
_errorState = false;
|
|
3371
|
+
currentDate = new Date();
|
|
3370
3372
|
get errorState() {
|
|
3371
3373
|
return this._errorState;
|
|
3372
3374
|
}
|
|
@@ -3537,38 +3539,23 @@ class DateRangePicker {
|
|
|
3537
3539
|
theme: this.getTheme(),
|
|
3538
3540
|
};
|
|
3539
3541
|
}
|
|
3542
|
+
getDateAddDay(day) {
|
|
3543
|
+
return addDay(this.currentDate, day);
|
|
3544
|
+
}
|
|
3540
3545
|
getDefaultRanges() {
|
|
3541
|
-
const today = new Date();
|
|
3542
|
-
const yesterday = new Date(today);
|
|
3543
|
-
yesterday.setDate(today.getDate() - 1);
|
|
3544
|
-
const last5Days = new Date(today);
|
|
3545
|
-
last5Days.setDate(today.getDate() - 4);
|
|
3546
|
-
const last10Days = new Date(today);
|
|
3547
|
-
last10Days.setDate(today.getDate() - 9);
|
|
3548
|
-
const last15Days = new Date(today);
|
|
3549
|
-
last15Days.setDate(today.getDate() - 14);
|
|
3550
|
-
const last30Days = new Date(today);
|
|
3551
|
-
last30Days.setDate(today.getDate() - 29);
|
|
3552
|
-
// Esta semana (lunes a domingo)
|
|
3553
|
-
const startOfWeek = new Date(today);
|
|
3554
|
-
const dayOfWeek = today.getDay();
|
|
3555
|
-
const daysToMonday = dayOfWeek === 0 ? 6 : dayOfWeek - 1; // Domingo = 0, necesitamos ir 6 días atrás
|
|
3556
|
-
startOfWeek.setDate(today.getDate() - daysToMonday);
|
|
3557
|
-
// Este mes
|
|
3558
|
-
const startOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
3559
|
-
// El mes pasado
|
|
3560
|
-
const startOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
|
|
3561
|
-
const endOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 0);
|
|
3562
3546
|
return {
|
|
3563
|
-
Hoy: [
|
|
3564
|
-
Ayer: [
|
|
3565
|
-
'Últimos 5 días': [
|
|
3566
|
-
'Últimos 10 días': [
|
|
3567
|
-
'Últimos 15 días': [
|
|
3568
|
-
'Últimos 30 días': [
|
|
3569
|
-
'Esta semana': [
|
|
3570
|
-
'Este mes': [
|
|
3571
|
-
'El mes pasado': [
|
|
3547
|
+
Hoy: [this.currentDate, this.currentDate],
|
|
3548
|
+
Ayer: [this.getDateAddDay(-1), this.getDateAddDay(-1)],
|
|
3549
|
+
'Últimos 5 días': [this.getDateAddDay(-4), this.currentDate],
|
|
3550
|
+
'Últimos 10 días': [this.getDateAddDay(-9), this.currentDate],
|
|
3551
|
+
'Últimos 15 días': [this.getDateAddDay(-14), this.currentDate],
|
|
3552
|
+
'Últimos 30 días': [this.getDateAddDay(-29), this.currentDate],
|
|
3553
|
+
'Esta semana': [weekStart(this.currentDate), weekEnd(this.currentDate)],
|
|
3554
|
+
'Este mes': [monthStart(this.currentDate), monthEnd(this.currentDate)],
|
|
3555
|
+
'El mes pasado': [
|
|
3556
|
+
monthStart(addDay(monthStart(this.currentDate), -1)),
|
|
3557
|
+
addDay(monthStart(this.currentDate), -1),
|
|
3558
|
+
],
|
|
3572
3559
|
};
|
|
3573
3560
|
}
|
|
3574
3561
|
getTheme() {
|