Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
intervalo de fechas angulares +2 lógica de fechas (excepto fines de semana)

Actualmente tengo un rango de selector de fecha mate. La lógica es que la fecha mínima en el calendario que el usuario puede seleccionar es + 2 días, por lo que, por ejemplo, la fecha de hoy es 20 (20 de julio de 2022), luego la fecha mínima es 22 (22 de julio de 2022) porque es + 2.

Pero si los próximos 2 días son fines de semana, por ejemplo, nuestra fecha actual es, digamos que hoy es 22 (22 de julio de 2022) si observa el calendario 23 y 24 son fines de semana, por lo que debe excluirse, por lo que +2 comenzaría desde 22 ( 22 de julio de 2022) y 25 (25 de julio de 2022), por lo que la fecha mínima sería 26 (26 de julio de 2022).

¿Cómo manejaríamos esta lógica en un selector de fecha?

# https://stackblitz.com/edit/angular-byrmnt-setsza?file=src%2Fapp%2Fdate-range-picker-overview-example.ts,src%2Findex.html,src%2Fapp%2Fdate-range-picker -resumen-ejemplo.html

#html

 <mat-form-field> <mat-label>Enter a date range</mat-label> <mat-date-range-input [rangePicker]="picker" [dateFilter]="weekendsDatesFilter"> <input matStartDate matInput placeholder="Start date" > <input matEndDate matInput placeholder="End date"> </mat-date-range-input> <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle> <mat-date-range-picker #picker></mat-date-range-picker> </mat-form-field>

#ts

 export class DateRangePickerOverviewExample { currentDate = new Date(); ngOnInit(): void { this.currentDate = new Date(this.currentDate.setDate(this.currentDate.getDate() + 2)); } weekendsDatesFilter = (d: Date): boolean => { const day = d.getDay(); /* Prevent Saturday and Sunday for select. */ return day !== 0 && day !== 6; }; }
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

¿Puedes comprobar esto haciendo clic aquí ? Espero que esto funcione para tí.

 import { Component } from '@angular/core'; @Component({ selector: 'date-range-picker-overview-example', templateUrl: 'date-range-picker-overview-example.html', styleUrls: ['date-range-picker-overview-example.css'], }) export class DateRangePickerOverviewExample { currentDate = new Date(); ngOnInit(): void { this.currentDate = new Date( this.currentDate.setDate(this.currentDate.getDate() + 2) ); !this.weekendsDatesFilter(this.currentDate) && this.weekendsHandler(); } weekendsDatesFilter = (d: Date): boolean => { const day = d.getDay(); /* Prevent Saturday and Sunday for select. */ return day !== 0 && day !== 6; }; weekendsHandler() { this.currentDate = new Date( this.currentDate.setDate(this.currentDate.getDate() + 1) ); !this.weekendsDatesFilter(this.currentDate) && this.weekendsHandler(); } }
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda