Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
¿Cómo puedo ajustar esta función para trabajar con el horario de verano?

Estaba usando este ejemplo para crear un calendario en angular. Pero hoy me di cuenta de que cuando finaliza el horario de verano, la fecha se repite y, a partir de ese momento, los días se interrumpen uno por uno.

Mira el stackblitz. El 7 de noviembre se repite. enlace de stackblitz al calendario

Este es el código que genera los días naturales. ¿Cómo ajusto esto para que DST no arruine todo?

 private getCalendarDays(date = new Date) { var startDate; startDate = this.getCalendarStartDay(date).getTime(); const calendarStartTime = startDate; return this.range(0, 41) .map(num => new Date(calendarStartTime + DAY_MS * num)); } private getCalendarStartDay(date = new Date) { const [year, month] = [date.getFullYear(), date.getMonth()]; const firstDayOfMonth = new Date(year, month, 1).getTime(); return this.range(1,7) .map(num => new Date(firstDayOfMonth - DAY_MS * num)) .find(dt => dt.getDay() === 0) } private range(start, end, length = end - start + 1) { return Array.from({ length }, (_, i) => start + i) }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No estoy muy seguro, pero imagino que puedes obtener las fechas a las 12 a.m. para evitar el problema.

 private getCalendarStartDay(date = new Date) { const [year, month] = [date.getFullYear(), date.getMonth()]; //see that I indicate the 1 of the month at 12:00:00 const firstDayOfMonth = new Date(year, month,1,12,0,0,0).getTime(); //well the range from 0 to 6 return this.range(0,6) .map(num => new Date(firstDayOfMonth - DAY_MS * num)) .find(dt => dt.getDay() === 0) }

NOTA: Recibí tu error en octubre, no en noviembre

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!