<commit_before>(function (env) {
    "use strict";
    env.ddg_spice_islamic_prayer_times = function(api_result) {

        if (!api_result || api_result.error || api_result.status_code === 0 || !api_result.items) {
            return Spice.failed('islamic_prayer_times');
        }

        DDG.require('moment.js', function() {

            function setDst(time, dst) {
                return dst === 1 ? time.add(dst, 'hours') : time;
            }

            function tz(time, offset) {
                var clone = time.clone();
                clone.utcOffset(offset);
                clone.add(time.utcOffset() - clone.utcOffset(), 'minutes');
                return clone;
            }

            function getClosest(timings, offset, local) {
                var date = local.format('YYYY-MM-DD');
                if ('date_for' in timings) {
                    date = tz(moment.utc(timings.date_for + ' ' + offset, 'YYYY-MM-DD Z'), offset).format('YYYY-MM-DD');
                    delete timings.date_for;
                }
                for (var property in timings) {
                    if (timings.hasOwnProperty(property)) {
                        var time = tz(moment.utc(date + ' ' + timings[property] + ' ' + offset, 'YYYY-MM-DD hh:mm a Z'), offset);
                        if (local.diff(time) < 0) {
                            var min = {
                                time: time,
                                diff: time.from(local),
                                title: DDG.capitalize(property)
                            };
                            return min;
                        }
                    }
                }
                return false;
            }

            function getList(timings) {
                var list = [];
                for (var property in timings) {
                    if (timings.hasOwnProperty(property) && property !== "date_for") {
                        list[DDG.capitalize(property)] = timings[property].toUpperCase();
                    }
                }
                return list;
            }

            function setFormat(closest, index) {
                return index === 0 ? closest.format('h:mm A') : closest.format('h:mm A, MMM D ') + '(Tomorrow)';
            }

            function setAddress(title, country_code, country, state) {
                if (title !== "") {
                    return country_code === "US" ? title.substr(0, title.lastIndexOf(",")) : title;
                }
                return state !== "" ? state + ', ' + country : country;
            }

            Spice.add({
                id: "islamic_prayer_times",
                name: "Islamic Prayer Times",
                data: api_result,
                meta: {
                    sourceName: "<NAME>",
                    sourceUrl: DDG.toHTTPS(api_result.link)
                },
                normalize: function(data) {
                    var offset  = parseInt(data.timezone),
                        dst     = parseInt(data.daylight),
                        local   = setDst(moment().utcOffset(offset), dst),
                        isha    = tz(moment.utc(data.items[0].date_for + ' ' + data.items[0].isha + ' ' + offset, 'YYYY-MM-DD hh:mm a Z'), offset),
                        index   = local.diff(isha) > 0 ? 1 : 0, // if isha, which is the last prayer in the day, is past, then get the results for tomorrow
                        closest = getClosest(data.items[index], offset, local);
                    return {
                        title: closest.title + ' at ' +  setFormat(closest.time, index),
                        subtitle: 'Next prayer time at ' + setAddress(data.title, data.country_code, data.country, data.state),
                        record_data: getList(data.items[index])
                    };
                },
                templates: {
                    group: 'list',
                    options: {
                        content: 'record',
                        moreAt: true
                    }<commit_msg>IslamicPrayerTimes: Move functions above the callback<commit_after>(function (env) {
    "use strict";

    function setDst(time, dst) {
        return dst === 1 ? time.add(dst, 'hours') : time;
    }

    function tz(time, offset) {
        var clone = time.clone();
        clone.utcOffset(offset);
        clone.add(time.utcOffset() - clone.utcOffset(), 'minutes');
        return clone;
    }

    function getClosest(timings, offset, local) {
        var date = local.format('YYYY-MM-DD');
        if ('date_for' in timings) {
            date = tz(moment.utc(timings.date_for + ' ' + offset, 'YYYY-MM-DD Z'), offset).format('YYYY-MM-DD');
            delete timings.date_for;
        }
        for (var property in timings) {
            if (timings.hasOwnProperty(property)) {
                var time = tz(moment.utc(date + ' ' + timings[property] + ' ' + offset, 'YYYY-MM-DD hh:mm a Z'), offset);
                if (local.diff(time) < 0) {
                    var min = {
                        time: time,
                        diff: time.from(local),
                        title: DDG.capitalize(property)
                    };
                    return min;
                }
            }
        }
        return false;
    }

    function getList(timings) {
        var list = [];
        for (var property in timings) {
            if (timings.hasOwnProperty(property) && property !== "date_for") {
                list[DDG.capitalize(property)] = timings[property].toUpperCase();
            }
        }
        return list;
    }

    function setFormat(closest, index) {
        return index === 0 ? closest.format('h:mm A') : closest.format('h:mm A, MMM D ') + '(Tomorrow)';
    }

    function setAddress(title, country_code, country, state) {
        if (title !== "") {
            return country_code === "US" ? title.substr(0, title.lastIndexOf(",")) : title;
        }
        return state !== "" ? state + ', ' + country : country;
    }

    env.ddg_spice_islamic_prayer_times = function(api_result) {

        if (!api_result || api_result.error || api_result.status_code === 0 || !api_result.items) {
            return Spice.failed('islamic_prayer_times');
        }

        DDG.require('moment.js', function() {

            Spice.add({
                id: "islamic_prayer_times",
                name: "Islamic Prayer Times",
                data: api_result,
                meta: {
                    sourceName: "<NAME>",
                    sourceUrl: DDG.toHTTPS(api_result.link)
                },
                normalize: function(data) {
                    var offset  = parseInt(data.timezone),
                        dst     = parseInt(data.daylight),
                        local   = setDst(moment().utcOffset(offset), dst),
                        isha    = tz(moment.utc(data.items[0].date_for + ' ' + data.items[0].isha + ' ' + offset, 'YYYY-MM-DD hh:mm a Z'), offset),
                        index   = local.diff(isha) > 0 ? 1 : 0, // if isha, which is the last prayer in the day, is past, then get the results for tomorrow
                        closest = getClosest(data.items[index], offset, local);
                    return {
                        title: closest.title + ' at ' +  setFormat(closest.time, index),
                        subtitle: 'Next prayer time at ' + setAddress(data.title, data.country_code, data.country, data.state),
                        record_data: getList(data.items[index])
                    };
                },
                templates: {
                    group: 'list',
                    options: {
                        content: 'record',
                        moreAt: true
                    }
{'fraction_non_alphanumeric': 0.1213173806767014, 'fraction_numerical': 0.0025730091341824263, 'mean_word_length': 1.313002082713478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3105296', 'n_tokens_mistral': 2197, 'n_tokens_neox': 2050, 'n_words': 447}