Search in sources :

Example 1 with NamedaysList

use of com.alexstyl.specialdates.events.namedays.NamedaysList in project Memento-Calendar by alexstyl.

the class SpecialGreekNamedaysCalculator method calculateForEasterDate.

NamedayBundle calculateForEasterDate(Date easter) {
    Node node = new SoundNode();
    NamedaysList namedaysList = new NamedaysList();
    for (EasternNameday easternNameday : easternNamedays) {
        int daysUntilEaster = easternNameday.getDateToEaster();
        Date date = easter.addDay(daysUntilEaster);
        for (String name : easternNameday.getNamesCelebrating()) {
            node.addDate(name, date);
            namedaysList.addNameday(date, name);
        }
    }
    appendSpecialScenarios(easter, node, namedaysList);
    return new NamedayBundle(node, namedaysList);
}
Also used : NamedaysList(com.alexstyl.specialdates.events.namedays.NamedaysList) EasternNameday(com.alexstyl.specialdates.events.namedays.calendar.EasternNameday) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Date(com.alexstyl.specialdates.date.Date)

Example 2 with NamedaysList

use of com.alexstyl.specialdates.events.namedays.NamedaysList in project Memento-Calendar by alexstyl.

the class RomanianNamedays method calculateEasterIfNecessary.

private void calculateEasterIfNecessary(int year) {
    if (romanianDate == null || romanianDate.getYear() != year) {
        romanianDate = calculator.calculateSpecialRomanianDayForYear(year);
        NamedaysList dateToNames = new NamedaysList();
        CharacterNode namesToDate = new CharacterNode();
        for (String name : names) {
            dateToNames.addNameday(romanianDate, name);
            namesToDate.addDate(name, romanianDate);
        }
        namedays = new NamedayBundle(namesToDate, dateToNames);
    }
}
Also used : NamedaysList(com.alexstyl.specialdates.events.namedays.NamedaysList) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle)

Example 3 with NamedaysList

use of com.alexstyl.specialdates.events.namedays.NamedaysList in project Memento-Calendar by alexstyl.

the class NamedayJSONParser method createBundleWith.

private static NamedayBundle createBundleWith(NamedayJSON locale, Node namesToDate) {
    NamedaysList dateToNames = new NamedaysList();
    JSONArray data = locale.getData();
    int size = data.length();
    for (int i = 0; i < size; i++) {
        try {
            JSONObject nameday;
            nameday = (JSONObject) data.get(i);
            String dateString = nameday.getString("date");
            Date theDate = getNamedaysFrom(dateString);
            JSONArray variations = nameday.getJSONArray("names");
            int numberOfVariations = variations.length();
            for (int varCount = 0; varCount < numberOfVariations; varCount++) {
                String variation = variations.getString(varCount);
                namesToDate.addDate(variation, theDate);
                dateToNames.addNameday(theDate, variation);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return new NamedayBundle(namesToDate, dateToNames);
}
Also used : NamedaysList(com.alexstyl.specialdates.events.namedays.NamedaysList) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) NamedayBundle(com.alexstyl.specialdates.events.namedays.NamedayBundle) Date(com.alexstyl.specialdates.date.Date)

Aggregations

NamedayBundle (com.alexstyl.specialdates.events.namedays.NamedayBundle)3 NamedaysList (com.alexstyl.specialdates.events.namedays.NamedaysList)3 Date (com.alexstyl.specialdates.date.Date)2 EasternNameday (com.alexstyl.specialdates.events.namedays.calendar.EasternNameday)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1