<commit_before>(function(DOM, COMPONENT_CLASS, I18N_DAYS, I18N_MONTHS) {
    "use strict";

    var htmlEl = DOM.find("html"),
        ampm = function(pos, neg) { return htmlEl.get("lang") === "en-US" ? pos : neg },
        formatISODate = function(value) { return value.toISOString().split("T")[0] },
        NOT_A_MOBILE_BROWSER = !("orientation" in window); // need to skip mobile/tablet browsers

    DOM.extend("input[type=date]", NOT_A_MOBILE_BROWSER, {
        constructor: function() {
            var calendar = DOM.create("div.{0}>a[unselectable=on]*2+p.{0}-header+table.{0}-days>thead>tr>th[unselectable=on]*7+tbody>tr*6>td*7", [COMPONENT_CLASS + "-calendar"]),
                displayedValue = DOM.create("span.{0}-value", [COMPONENT_CLASS]),
                // IE8 doesn't suport color:transparent - use background-color instead
                transparentText = document.addEventListener ? "transparent" : this.style("background-color"),
                offset = this.offset();

            this
                // remove legacy dateinput implementation if it exists
                // also set value to current time to trigger watchers later
                .set({type: "text", value: Date.now()})
                // hide original input text
                .style("color", transparentText)
                // handle arrow keys, esc etc.
                .on("keydown", this.onCalendarKeyDown.bind(this, calendar), ["which", "shiftKey"])
                // sync picker visibility on focus/blur
                .on(["focus", "click"], this.onCalendarFocus.bind(this, calendar))
                .on("blur", this.onCalendarBlur.bind(this, calendar))
                .before(calendar, displayedValue);

            calendar
                .on("mousedown", this.onCalendarClick.bind(this, calendar))
                .style({
                    "margin-left": (offset.width - calendar.offset().width) / 2,
                    "margin-top": offset.height,
                    "z-index": 1 + (this.style("z-index") | 0)
                })
                .hide(); // hide calendar to trigger show animation properly later

            // copy input CSS
            displayedValue.style(this.style(
                ["width", "height", "font", "padding", "text-align", "border-width", "box-sizing"]));

            this.parent("form").on("reset", this.onFormReset.bind(this));
            // FIXME: "undefined" -> "value" after migrating to better-dom 1.7.5
            this.watch("undefined", this.onValueChanged.bind(this, displayedValue,
                calendar.find("p"), calendar.findAll("th"), calendar.findAll("td")));
            // trigger watchers to build the calendar
            this.set(this.get("defaultValue"));
            // display calendar for autofocused elements
            if (this.matches(":focus")) this.fire("focus");
        },
        onValueChanged: function(displayedValue, caption, weekdays, days, value) {
            var year, month, date, iterDate;

            value = new Date(value);

            // display formatted date value for original input
            if (value.getTime()) {
                displayedValue
                    .set("")
                    // build RFC 1123 Time Format
                    .append(DOM.create("span").i18n(I18N_DAYS[ampm(value.getDay() ? value.getDay() - 1 : 6, value.getDay())]))
                    .append(",&nbsp;" + ((value.getDate() > 9 ? "" : "0") + value.getDate()) + "&nbsp;")
                    .append(DOM.create("span").i18n(I18N_MONTHS[value.getMonth()].substr(0, 3)))
                    .append("&nbsp;" + value.getFullYear());
            } else {
                displayedValue.set("");

                value = new Date();
            }

            month = value.getMonth();
            date = value.getDate();
            year = value.getFullYear();

            // update calendar caption
            caption.i18n(I18N_MONTHS[month]).set("textContent", " " + year);
            // update calendar weekday captions
            weekdays.each(function(el, index) {
                el.i18n(I18N_DAYS[ampm(index ? index - 1 : 6, index)]);
            });
            // update calendar content
            iterDate = new Date(year, month, 0, 12);<commit_msg>fix incorrect day of week in displayed value<commit_after>(function(DOM, COMPONENT_CLASS, I18N_DAYS, I18N_MONTHS) {
    "use strict";

    var htmlEl = DOM.find("html"),
        ampm = function(pos, neg) { return htmlEl.get("lang") === "en-US" ? pos : neg },
        formatISODate = function(value) { return value.toISOString().split("T")[0] },
        NOT_A_MOBILE_BROWSER = !("orientation" in window); // need to skip mobile/tablet browsers

    DOM.extend("input[type=date]", NOT_A_MOBILE_BROWSER, {
        constructor: function() {
            var calendar = DOM.create("div.{0}>a[unselectable=on]*2+p.{0}-header+table.{0}-days>thead>tr>th[unselectable=on]*7+tbody>tr*6>td*7", [COMPONENT_CLASS + "-calendar"]),
                displayedValue = DOM.create("span.{0}-value", [COMPONENT_CLASS]),
                // IE8 doesn't suport color:transparent - use background-color instead
                transparentText = document.addEventListener ? "transparent" : this.style("background-color"),
                offset = this.offset();

            this
                // remove legacy dateinput implementation if it exists
                // also set value to current time to trigger watchers later
                .set({type: "text", value: Date.now()})
                // hide original input text
                .style("color", transparentText)
                // handle arrow keys, esc etc.
                .on("keydown", this.onCalendarKeyDown.bind(this, calendar), ["which", "shiftKey"])
                // sync picker visibility on focus/blur
                .on(["focus", "click"], this.onCalendarFocus.bind(this, calendar))
                .on("blur", this.onCalendarBlur.bind(this, calendar))
                .before(calendar, displayedValue);

            calendar
                .on("mousedown", this.onCalendarClick.bind(this, calendar))
                .style({
                    "margin-left": (offset.width - calendar.offset().width) / 2,
                    "margin-top": offset.height,
                    "z-index": 1 + (this.style("z-index") | 0)
                })
                .hide(); // hide calendar to trigger show animation properly later

            // copy input CSS
            displayedValue.style(this.style(
                ["width", "height", "font", "padding", "text-align", "border-width", "box-sizing"]));

            this.parent("form").on("reset", this.onFormReset.bind(this));
            // FIXME: "undefined" -> "value" after migrating to better-dom 1.7.5
            this.watch("undefined", this.onValueChanged.bind(this, displayedValue,
                calendar.find("p"), calendar.findAll("th"), calendar.findAll("td")));
            // trigger watchers to build the calendar
            this.set(this.get("defaultValue"));
            // display calendar for autofocused elements
            if (this.matches(":focus")) this.fire("focus");
        },
        onValueChanged: function(displayedValue, caption, weekdays, days, value) {
            var year, month, date, iterDate;

            displayedValue.set("");
            value = new Date(value);

            // display formatted date value for original input
            if (value.getTime()) {
                displayedValue
                    // build RFC 1123 Time Format
                    .append(DOM.create("span").i18n(I18N_DAYS[value.getDay() ? value.getDay() - 1 : 6]))
                    .append(",&nbsp;" + ((value.getDate() > 9 ? "" : "0") + value.getDate()) + "&nbsp;")
                    .append(DOM.create("span").i18n(I18N_MONTHS[value.getMonth()].substr(0, 3)))
                    .append("&nbsp;" + value.getFullYear());
            } else {
                value = new Date();
            }

            month = value.getMonth();
            date = value.getDate();
            year = value.getFullYear();

            // update calendar caption
            caption.i18n(I18N_MONTHS[month]).set("textContent", " " + year);
            // update calendar weekday captions
            weekdays.each(function(el, index) {
                el.i18n(I18N_DAYS[ampm(index ? index - 1 : 6, index)]);
            });
            // update calendar content
            iterDate = new Date(year, month, 0, 12);
{'fraction_non_alphanumeric': 0.1451783821971035, 'fraction_numerical': 0.012009890498057224, 'mean_word_length': 1.9401176877812392, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '342489', 'n_tokens_mistral': 2452, 'n_tokens_neox': 2300, 'n_words': 512}