private int setEveryValues(Calendar calendar) {
        int nextTriggerCalendarFieldToIncrease = 0;

        // Set second to 0
        calendar.set(Calendar.SECOND, 0);

        // Set minute from options in next calendar
        if (triggerEveryJSONObject.has("minute")) {
            calendar.set(Calendar.MINUTE, triggerEveryJSONObject.optInt("minute"));
            // One hour has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.HOUR;
        }

        // Set hour from options in next calendar
        if (triggerEveryJSONObject.has("hour")) {
            calendar.set(Calendar.HOUR_OF_DAY, triggerEveryJSONObject.optInt("hour"));
            resetTimeIfNotSetByTrigger(calendar);
            // One day has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.DAY_OF_YEAR;
        }

        // Set day from options in next calendar
        if (triggerEveryJSONObject.has("day")) {
            calendar.set(Calendar.DAY_OF_MONTH, triggerEveryJSONObject.optInt("day"));
            resetTimeIfNotSetByTrigger(calendar);
            // One month has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.MONTH;
        }
 
        // Set weekday (day of week) from options in next calendar (1 = Monday, 7 = Sunday)
        if (triggerEveryJSONObject.has("weekday")) {
            // Calendar.MONDAY is 2, so we have to add 1 to the weekday
            calendar.set(Calendar.DAY_OF_WEEK, 1 + triggerEveryJSONObject.optInt("weekday"));

            resetTimeIfNotSetByTrigger(calendar);

            // One week has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.WEEK_OF_YEAR;
        }
 
        // Set weekOfMonth from options in next calendar
        if (triggerEveryJSONObject.has("weekOfMonth")) {
 
            int weekOfMonth = triggerEveryJSONObject.optInt("weekOfMonth");
            calendar.set(Calendar.WEEK_OF_MONTH, weekOfMonth);
 
            // Reset hour/minute
            resetTimeIfNotSetByTrigger(calendar);
            resetWeekdayIfNotSetByTrigger(calendar);

            // If the week of month is the first week, set day of month to 1
            if (weekOfMonth == 1) {
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                // Correct weekday if it is set, but prevent jumping to the last month
                setWeekdayIfInFuture(calendar);
            }

            // One month has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.MONTH;
        }
 
        // Set week of year from options in next calendar
        if (triggerEveryJSONObject.has("week")) {
            int weekOfYear = triggerEveryJSONObject.optInt("week");
            calendar.set(Calendar.WEEK_OF_YEAR, weekOfYear);

            resetTimeIfNotSetByTrigger(calendar);
            resetWeekdayIfNotSetByTrigger(calendar);
            
            // If the week of year is the first week, set day of year to 1
            if (weekOfYear == 1) {
                calendar.set(Calendar.DAY_OF_YEAR, 1);
                // Correct weekday if it is set, but prevent jumping to the last year
                setWeekdayIfInFuture(calendar);
            }

            nextTriggerCalendarFieldToIncrease = Calendar.YEAR;
        }
 
        // Set month from options in next calendar
        if (triggerEveryJSONObject.has("month")) {
            // The first month is 0 for Calendar
            calendar.set(Calendar.MONTH, triggerEveryJSONObject.optInt("month") - 1);

            resetTimeIfNotSetByTrigger(calendar);
            resetDayIfNotSetByTrigger(calendar);

            // One year has to be added for the next trigger
            nextTriggerCalendarFieldToIncrease = Calendar.YEAR;
        }

        return nextTriggerCalendarFieldToIncrease;
    }
Set trigger.every values like { month: 10, day: 27, ...} in the given calendar.
@param calendar
@return The next higher {@link Calendar} field that has to be increase from the highest trigger.every option
For e.g. returns {@link Calendar.HOUR} when maximum minute is set,
or {@link Calendar.DAY_OF_YEAR} when maximum hour is set.
Returns 0 if no or wrong trigger.every values are set.
src/android/trigger/TriggerHandlerEvery.java