Component shows now the year week numbers #738
|
@ -84,23 +84,18 @@ export default class Calendar extends FormInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
getWeekdays() {
|
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;
|
if (!this.moment) return;
|
||||||
|
|
||||||
const totalSlots = this.lastDay() + this.weekdayOffset;
|
const totalSlots = this.lastDay() + this.weekdayOffset;
|
||||||
const weeks = Math.ceil(totalSlots / 7);
|
const weeks = Math.ceil(totalSlots / 7);
|
||||||
// console.log(this.lastDay());
|
|
||||||
const m = this.moment(this.defaultDate);
|
const dated = this.moment(this.defaultDate);
|
||||||
const firstWeekNumber = m.set('date', 1).isoWeek();
|
const firstWeekNumber = dated.set('date', 1).isoWeek();
|
||||||
|
|
||||||
const weekNumbers = [];
|
const weekNumbers = [];
|
||||||
for (let w = 0; w < weeks; w++) {
|
for (let w = 0; w < weeks; w++) {
|
||||||
let weekNumber = firstWeekNumber;
|
let weekNumber = firstWeekNumber;
|
||||||
if (m.get('month') == 0 && firstWeekNumber > 1 && w > 0)
|
if (dated.get('month') == 0 && firstWeekNumber > 1 && w > 0)
|
||||||
weekNumber = 0;
|
weekNumber = 0;
|
||||||
|
|
||||||
weekNumbers.push(weekNumber + w);
|
weekNumbers.push(weekNumber + w);
|
||||||
|
|
Loading…
Reference in New Issue