Component shows now the year week numbers #738

Merged
carlosjr merged 4 commits from 2389-calendar_weeks into dev 2021-09-20 08:50:12 +00:00
1 changed files with 4 additions and 9 deletions
Showing only changes of commit 69346a17a0 - Show all commits

View File

@ -84,23 +84,18 @@ export default class Calendar extends FormInput {
}
getWeekdays() {
// A partir de la fecha "default", ir al primer mes del año
// y dividir el numero de días del mes entre 7 para obtener el numero de semanas
// e ir sumando hasta llegar al mes actual
// a partir de ese numero incrementar segun el numero de semanas del mes
if (!this.moment) return;
const totalSlots = this.lastDay() + this.weekdayOffset;
const weeks = Math.ceil(totalSlots / 7);
// console.log(this.lastDay());
const m = this.moment(this.defaultDate);
const firstWeekNumber = m.set('date', 1).isoWeek();
const dated = this.moment(this.defaultDate);
const firstWeekNumber = dated.set('date', 1).isoWeek();
const weekNumbers = [];
for (let w = 0; w < weeks; w++) {
let weekNumber = firstWeekNumber;
if (m.get('month') == 0 && firstWeekNumber > 1 && w > 0)
if (dated.get('month') == 0 && firstWeekNumber > 1 && w > 0)
weekNumber = 0;
weekNumbers.push(weekNumber + w);