code: public static long periodEnd(long now, long period)
    {
      QDate localCalendar = QDate.allocateLocalDate();
      
      long endTime = periodEnd(now, period, localCalendar);
      
      QDate.freeLocalDate(localCalendar);
      
      return endTime;
    }
docs: Calculates the next period end.  The calculation is in local time.
  
  @param now the current time in GMT ms since the epoch
  
  @return the time of the next period in GMT ms since the epoch