fix calendar
This commit is contained in:
parent
ece995352f
commit
09a7d48a31
2 changed files with 7 additions and 12 deletions
2
assets/dist/calendar.min.js
vendored
2
assets/dist/calendar.min.js
vendored
|
|
@ -1 +1 @@
|
|||
function getDatesInMonth(e){const t=dayjs().month(e).year(),a=dayjs(new Date(t,e,0)).daysInMonth(),n={};for(let o=1;o<=a;o++){const a=dayjs(new Date(t,e,o)),s=a.format("dd")[0].toUpperCase();n[parseInt(a.format("DD"))]={sessions:[],full:a.format("DD-MM-YYYY"),initial:s}}return n}async function getMapadoEvent(e){const t="ticketings/"+e,a={method:"POST",body:JSON.stringify({requestEndPoint:t,requestParams:[],requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"eventDateList",subfields:[{name:"@id"},{name:"bookableStock"}]}]})},n=await fetch("/mapado-api.json",a),o=(await n.json())["hydra:member"];console.log("Événement Mapado",o)}async function getMapadoDates(e){const t=dayjs().month(e).startOf("month").format("YYYY-MM-DD"),a=[{name:"itemsPerPage",value:100},{name:"contract",value:"1941"},{name:"after",value:t},{name:"before",value:dayjs(t).add(1,"month").format("YYYY-MM-DD")},{name:"order",value:"asc"}],n={method:"POST",body:JSON.stringify({requestEndPoint:"event_dates",requestParams:a,requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"ticketing",subfields:[{name:"@id"},{name:"title"},{name:"slug"},{name:"venue",subfields:[{name:"@id"},{name:"address"},{name:"zipCode"},{name:"city"},{name:"countryCode"},{name:"timezone"}]}]}]})},o=await fetch("/mapado-api.json",n),s=(await o.json())["hydra:member"];console.log(`Événements Mapado de ${dayjs(t).format("MMMM")} ${dayjs(t).format("YYYY")}`,s);return s.map((e=>({day:getDay(e),title:e.ticketing.title,startTime:getStartTime(e),ticketingUrl:getTicketingUrl(e),id:getId(e)})))}function getDay(e){return e.startDate.slice(0,10).split("-")[2]}function getStartTime(e){const t=e.startDate.slice(11,19);return dayjs(`2000-01-01T${t}`).format("HH[h]mm")}function getTicketingUrl(e){return"https://cdn-besancon.mapado.com/event/"+e.ticketing.slug}function getId(e){const t=e.ticketing["@id"].split("/");return parseInt(t[3])}function createEmptyCalendar(){const e={};for(let t=dayjs().month();t<21;t++){const a=(t-1)%12+1,n=dayjs().month(a-1).daysInMonth();e[a]={};for(let t=1;t<=n;t++){const n=dayjs().month(a-1).date(t),o=n.format("dd")[0].toUpperCase();e[a][t]={sessions:[],full:n.format("DD-MM-YYYY"),initial:o,index:parseInt(n.format("DD")),indexInWeek:0===n.day()?7:n.day()}}}return e}async function getCurrentSeasonCalendar(){const e={calendar:createEmptyCalendar()},t={method:"POST",body:JSON.stringify(e)},a=await fetch("/get-current-season-calendar.json",t);return await a.json()}async function updateMapadoEvent(e){const t={method:"POST",headers:new Headers,redirect:"follow",body:JSON.stringify({pageUri:e})},a=await fetch("/update-mapado-event.json",t),n=await a.json();return console.log("Séance récupérées de Mapado",n),n}function dateToFrench(e){return(e=dayjs(e)).format("D MMMM YYYY")}dayjs.locale("fr");
|
||||
function getDatesInMonth(e){const t=dayjs().month(e).year(),a=dayjs(new Date(t,e,0)).daysInMonth(),n={};for(let o=1;o<=a;o++){const a=dayjs(new Date(t,e,o)),s=a.format("dd")[0].toUpperCase();n[parseInt(a.format("DD"))]={sessions:[],full:a.format("DD-MM-YYYY"),initial:s}}return n}async function getMapadoEvent(e){const t="ticketings/"+e,a={method:"POST",body:JSON.stringify({requestEndPoint:t,requestParams:[],requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"eventDateList",subfields:[{name:"@id"},{name:"bookableStock"}]}]})},n=await fetch("/mapado-api.json",a),o=(await n.json())["hydra:member"];console.log("Événement Mapado",o)}async function getMapadoDates(e){const t=dayjs().month(e).startOf("month").format("YYYY-MM-DD"),a=[{name:"itemsPerPage",value:100},{name:"contract",value:"1941"},{name:"after",value:t},{name:"before",value:dayjs(t).add(1,"month").format("YYYY-MM-DD")},{name:"order",value:"asc"}],n={method:"POST",body:JSON.stringify({requestEndPoint:"event_dates",requestParams:a,requestFields:[{name:"startDate"},{name:"bookableStock"},{name:"ticketing",subfields:[{name:"@id"},{name:"title"},{name:"slug"},{name:"venue",subfields:[{name:"@id"},{name:"address"},{name:"zipCode"},{name:"city"},{name:"countryCode"},{name:"timezone"}]}]}]})},o=await fetch("/mapado-api.json",n),s=(await o.json())["hydra:member"];console.log(`Événements Mapado de ${dayjs(t).format("MMMM")} ${dayjs(t).format("YYYY")}`,s);return s.map((e=>({day:getDay(e),title:e.ticketing.title,startTime:getStartTime(e),ticketingUrl:getTicketingUrl(e),id:getId(e)})))}function getDay(e){return e.startDate.slice(0,10).split("-")[2]}function getStartTime(e){const t=e.startDate.slice(11,19);return dayjs(`2000-01-01T${t}`).format("HH[h]mm")}function getTicketingUrl(e){return"https://cdn-besancon.mapado.com/event/"+e.ticketing.slug}function getId(e){const t=e.ticketing["@id"].split("/");return parseInt(t[3])}function createEmptyCalendar(){const e={},t=dayjs().month();for(let a=t;a<t+12;a++){const t=dayjs().month(a),n=t.daysInMonth();e[t.month()+1]={};for(let a=1;a<=n;a++){const n=t.date(a),o=n.format("dd")[0].toUpperCase();e[t.month()+1][a]={sessions:[],full:n.format("DD-MM-YYYY"),initial:o,index:parseInt(n.format("DD")),indexInWeek:0===n.day()?7:n.day()}}}return e}async function getCurrentSeasonCalendar(){const e={calendar:createEmptyCalendar()},t={method:"POST",body:JSON.stringify(e)},a=await fetch("/get-current-season-calendar.json",t);return await a.json()}async function updateMapadoEvent(e){const t={method:"POST",headers:new Headers,redirect:"follow",body:JSON.stringify({pageUri:e})},a=await fetch("/update-mapado-event.json",t),n=await a.json();return console.log("Séance récupérées de Mapado",n),n}function dateToFrench(e){return(e=dayjs(e)).format("D MMMM YYYY")}dayjs.locale("fr");
|
||||
|
|
@ -151,23 +151,18 @@ function createEmptyCalendar() {
|
|||
|
||||
const currentMonth = dayjs().month();
|
||||
|
||||
for (let month = currentMonth; month < 21; month++) {
|
||||
const normalizedMonth = ((month - 1) % 12) + 1;
|
||||
for (let month = currentMonth; month < currentMonth + 12; month++) {
|
||||
const date = dayjs().month(month);
|
||||
const daysInMonth = date.daysInMonth();
|
||||
|
||||
const daysInMonth = dayjs()
|
||||
.month(normalizedMonth - 1)
|
||||
.daysInMonth();
|
||||
|
||||
calendar[normalizedMonth] = {};
|
||||
calendar[date.month() + 1] = {};
|
||||
|
||||
for (let day = 1; day <= daysInMonth; day++) {
|
||||
const currentDay = dayjs()
|
||||
.month(normalizedMonth - 1)
|
||||
.date(day);
|
||||
const currentDay = date.date(day);
|
||||
|
||||
const dayInitial = currentDay.format("dd")[0].toUpperCase();
|
||||
|
||||
calendar[normalizedMonth][day] = {
|
||||
calendar[date.month() + 1][day] = {
|
||||
sessions: [],
|
||||
full: currentDay.format("DD-MM-YYYY"),
|
||||
initial: dayInitial,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue