maandag 20 april 2020

Importing a (part of a) PDF schedule into Google Calendar with #GoogleAppsScript


Twice a year I get a schedule like the schedule above. It is part of a PDF document. Every row is a 'shift' in which asylum applications are processed at Airport Schiphol in the so called border procedure. In every 'shift' there are 5 days for a lawyer.

How to get all these days into my calendar.

I copy the schedule and paste it into a mail to myself with $$$$$ in the subject.

An then:

function shiftToCalendar(){
  
  var kindOfShiftDays = [[0,"dagmineen"],[1,"a&c eerste gehoor"],[2,"a&c nader gehoor"],[3,"zienswijze"],[4,"beschikking"]]
  var threads = GmailApp.search("newer_than:1d from:me subject:$$$$$");
  var message = threads[0].getMessages()[0];
  
  if(message){
    
  var shifts = message.getBody().split(/A11608/g); 
    
    for(var d=1;d<shifts.length;d++){
      
      var shift = shifts[d];
      
      if(/AC /.test(dienst) && shift.match(/\d{1,2}\-\d{1,2}\-\d{4}/gm) !== null){
            
        var shiftDays = shift.match(/\d{1,2}\-\d{1,2}\-\d{4}/gm);
        
            for(var e=0;e<shiftDays.length;e++){
             
              var hlpShiftDay = shiftDays[e].split(/\-/g);
              var shiftDay = new Date(hlpShiftDay[2],hlpShiftDay[1]-1,hlpShiftDay[0]); 
              
              for(var f=0;f<kindOfShiftDays.length;f++){
                  
                if(kindOfShiftDays[f][0] == e){var what = kindOfShiftDays[f][1]}
                 
                  }
            
              CalendarApp.getCalendarById(MIJNKALENDER()).createAllDayEvent(what,shiftDay).setColor(d);
            
            }
        }
    }  
  
    message.moveToTrash();
  }  
}

vrijdag 17 april 2020

Get the number of the week with #GoogleAppsScript

Javascript does not have a method to get the number of the week.

It seems that the fourth of January always is in the first week of a year. If that is correct GAS can help to get the number of the week we are living in.

Very interesting to know.


function getWeekNumber(){
  
  var thisYear = (new Date()).getFullYear();
  var fourthDayOfTheYear = new Date(thisYear,0,4);
  
  var dayFirstMonday = fourthDayOfTheYear.getDate() + 8 - fourthDayOfTheYear.getDay();
  var dateFirstMonday = new Date(thisYear,0,dayFirstMonday);
  var msFirstMonday = dateFirstMonday.getTime(); 
  
  var msDateToday = (new Date()).getTime(); 
  var msOneWeek = 7*24*60*60*1000; 

  for(var i=0;i<52;i++){
    
    var msNextMonday = msFirstMonday + (i * msOneWeek);
    var msComingNextMonday = msNextMonday + msOneWeek;
    
    if(msNextMonday <= msDateToday && msDateToday < msComingNextMonday){
      
      var weekNumber = i+2;
      
    }
  }
  return weekNumber;
}  



vrijdag 10 april 2020

Combining Google Meet and Google Voice outside the US, Canada



In times of social distancing communicating with a detained person for the communication with whom an interpreter is needed is difficult. Because of rules a detained person can not be called but has to call me and an interpreter can not call me but has to be called.

With Google Meet someone can call in into a (non) video meeting but with Google Meet it is not possible to call a number that is not a number from the US or Canada.

Luckily there is Voicemeeter Banana an Advanced Audio Mixer Application endowed with Virtual Audio Device used as Virtual I/O to mix and manage any audio sources from or to any audio devices or applications (in their words).

With the audio mixer you can mix-minus (yourself and) Google Meet and (a softphone like) Google Voice. And it works!

Google Meet audio settings:



Google Voice audio settings: