private void drawMonth(int yy, int xx, Calendar cal, int hday) {
      String str = MONTH[cal.get(Calendar.MONTH) - Calendar.JANUARY] + " " +
            cal.get(Calendar.YEAR);
      area.set(yy++, xx+(20-str.length())/2, calbg, str);
      area.set(yy++, xx, calbg, "Mo Tu We Th Fr Sa Su");
      
      int mon= cal.get(Calendar.MONTH);
      cal.set(Calendar.DAY_OF_MONTH, 1);
      cal.set(Calendar.SECOND, 0);
      cal.set(Calendar.MINUTE, 0);
      // Use 12 midday to avoid problems when clock goes forwards or back
      cal.set(Calendar.HOUR_OF_DAY, 12);
      while (true) {
         long tim = cal.getTimeInMillis();
         if (mon != cal.get(Calendar.MONTH))
            break;
         long[] ss = get_moons(tim-12*3600*1000);	// Start of day
         long[] es = get_moons(tim+12*3600*1000);	// End of day
         boolean znew= ss[1] != es[1];
         boolean zfull= tim-12*3600*1000 < ss[1] && tim+12*3600*1000 > ss[1];

         // Put Sunday at the end
         int wday= (cal.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY + 13) % 7;
         int mday = cal.get(Calendar.DAY_OF_MONTH);
         area.set(yy, xx + 3*wday,
                  mday == hday ? calhi :
                  zfull ? calfull : znew ? calnew : calbg, 
                  String.format("%2d", mday));

         cal.set(Calendar.DAY_OF_MONTH, mday+1);
         if (wday == 6) yy++;
      }
   }