0

This is how my event are displaying at the moment in my calendar:events

And this is the part of code that make this visualisation happens:

eventContent: function(info) { 
     const title = info.event.title;
     const nomeUtente = info.event.extendedProps.nomeUtente;
     if (nomeUtente){
            return{  
                html: "<b>" + title + "</b> <br><i> " + nomeUtente + "</i>"  
             }         
      }
},

I would like to display near the event.title, left side the duration of the event; like if an event last 3 hours i would like to see near "Ferie" (event.title) the number 3, and so on.

I tried adding something like:

....
const duration = info.event.end - info.event.start; 
if (nomeUtente){
    return{  
        html: "<b>" + duration + title + "</b> <br><i> " + nomeUtente + "</i>"  
    }         
}

but it was giving me some number extra high, i think it's showing me the seconds, but i would love to see it in hour

I also tried looking here on SO but only found out solution about old version of FC, that still use "eventRender".

Thanks in advance!


I cannot answer my post becuase they close my question, but the solution I found for my situation is:
eventContent: function(info) { 
   const title = info.event.title;
   const nomeUtente = info.event.extendedProps.nomeUtente;
   var pausaPranzo = info.event.extendedProps.pausaPranzo;
   if (title != ""){

        var start = info.event.start.getTime();
        var end = info.event.end.getTime();
        if(pausaPranzo != 0){
             var pp = pausaPranzo * 60000;
             var millisec = (end - start) - pp;
             var hour = millisec / 36e5;
        }else if(pausaPranzo == 0){
             if (title == eventi[2] || title == eventi[3]){
                  var millisec = (end - start) - 5400000;
                  var hour = millisec / 36e5;
             }else{
                  var millisec = end - start;
                  var hour = millisec / 36e5;
             }
         }
  }
  if (nomeUtente){
       return { 
           html: "<b>&nbsp;" + hour +" | " + title + "</b> <br>&nbsp;<i> " + nomeUtente + "</i>"
       } 
   }
}

And this was the visual result: result

nano
  • 65
  • 6

0 Answers0