<commit_before>React = require('react/addons');

module.exports = React.createClass({
    getInitialState: function(){
        var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();
        if (minutes >= 0 && minutes < 15) {
            minutes = 15;
        } else if (minutes >= 15 && minutes < 30) {
            minutes = 30;
        } else if (minutes >= 30 && minutes < 45) {
            minutes = 45;
        } else if (minutes >= 45 && minutes < 60) {
            minutes = "00";
            if (hours == 23) {
                hours = 0;
            } else {
                hours++;
            }
        }

        var defaultHour = hours;
        if (defaultHour == 0) {
            defaultHour = 12;
        } else if (defaultHour > 12) {
            defaultHour = defaultHour - 12;
        }

        var ampm = (now.getHours() > 11 ? "PM" : "AM");
        var timeZone = -(now.getTimezoneOffset()/60) + "00";
        var dateTimeString = (now.getMonth() + 1) +  "/" + (now.getDate()) + "/" + now.getFullYear() + " " + hours + ":" + minutes  + " " + timeZone;
        var initDate = new Date(dateTimeString);

        return {
            date: initDate.getTime(),
            defaultHour: defaultHour,
            dateString: this.getDateValueString(initDate),
            hourString: defaultHour + "",
            minuteString: minutes + "",
            ampmString: ampm,
            timeZoneString: timeZone,
            timeZoneText: ""
        }
    },
    updateDate: function(){
        var timeZoneText = this.state.timeZoneText;
        if (timeZoneText == "") {
            timeZoneText = $("#dateTimezone option:selected").text();
        }
        var tzOffset = this.state.timeZoneString;
        if (tzOffset.indexOf("-") < 0){
            tzOffset = "+" + tzOffset;
        }
        newDate = new Date(this.state.dateString + " " + this.state.hourString + ":" + this.state.minuteString + " " + this.state.ampmString + " " + tzOffset);
        this.setState(
            {
                date: newDate.getTime(),
                timeZoneText: timeZoneText
            },
            this.props.onChange);
    },
    componentDidUpdate: function(prevProps, prevState) {
        
    },
    getDateString: function(dateObj) {
        
        var days = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
        var months = new Array("January", "February", "March","April", "May", "June", "July","August", "September", "October","November", "December");

        var day = days[dateObj.getDay()];
        var month = months[dateObj.getMonth()];
        var date = dateObj.getDate();
        var year = dateObj.getFullYear();

        return day + ", " + month + " " + date + ", " + year;
    },
    getDateValueString: function(dateObj) {
        return (dateObj.getMonth() +1) + "/" + dateObj.getDate() + "/" + dateObj.getFullYear();
    },
    getDates: function(){
        var dateList = new Array();
        var maxDays = this.props.maxDays;
        for (i=0;i<maxDays;i++) {
            var newDate = new Date();
            newDate.setDate(newDate.getDate() + i);
            dateList.push( <option key={i} value={this.getDateValueString(newDate)}>{this.getDateString(newDate)}</option> );
        }

        return dateList;
    },
    getTimeZones: function(){
        var timeZones = new Array();
        var standardUSZones = ["SAMT","MSK","EET","CET","GMT","AST","EST","CST","MST","PST","AKST","HAST"];
        var standardUSOffsets = ["400","300","200","100","000","-400","-500","-600","-700","-800","-900","-1000"];
        var daylightUSZones = ["MSD","EEST","CEST","BST","GMT","ADT","EDT","CDT","MDT","PDT","AKDT","HADT"];
        var daylightUSOffsets = ["400","300","200","100","000","-300","-400","-500","-600","-700","-800","-900"];;

        
        var now = new Date();
        var isDst =  now.getTimezoneOffset() < this.stdTimezoneOffset();
        

        for (i=0;i<standardUSZones.length;i++){

            var value;
            var display;

            if (isDst){
                value = daylightUSOffsets[i];
                display = daylightUSZones[i];
            } else {
                value = standardUSOffsets[i];
                display = standardUSZones[i];
            }

            timeZones.push(<option key={i} value={value} >{display}</option>)
        }

        return timeZones;
    },
    stdTimezoneOffset: function() {
        var now = new Date();
        var jan = new Date(now.getFullYear(), 0, 1);
        var jul = new Date(now.getFullYear(), 6, 1);
        return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
    },
    handleDateChange: function(event){
        this.setState({dateString: event.target.value},this.updateDate);
    },<commit_msg>Adding logic to check selected date to see if it is in DST or not and set the state for isDst. Timezone dropdown will serenader based on isDst state value<commit_after>React = require('react/addons');

module.exports = React.createClass({
    getInitialState: function(){
        var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();
        if (minutes >= 0 && minutes < 15) {
            minutes = 15;
        } else if (minutes >= 15 && minutes < 30) {
            minutes = 30;
        } else if (minutes >= 30 && minutes < 45) {
            minutes = 45;
        } else if (minutes >= 45 && minutes < 60) {
            minutes = "00";
            if (hours == 23) {
                hours = 0;
            } else {
                hours++;
            }
        }

        var defaultHour = hours;
        if (defaultHour == 0) {
            defaultHour = 12;
        } else if (defaultHour > 12) {
            defaultHour = defaultHour - 12;
        }

        var ampm = (now.getHours() > 11 ? "PM" : "AM");
        var timeZone = -(now.getTimezoneOffset()/60) + "00";
        var dateTimeString = (now.getMonth() + 1) +  "/" + (now.getDate()) + "/" + now.getFullYear() + " " + hours + ":" + minutes  + " " + timeZone;
        var initDate = new Date(dateTimeString);

        return {
            date: initDate.getTime(),
            defaultHour: defaultHour,
            dateString: this.getDateValueString(initDate),
            hourString: defaultHour + "",
            minuteString: minutes + "",
            ampmString: ampm,
            timeZoneString: timeZone,
            timeZoneText: "",
            isDst: this.checkIfDST(now)
        }
    },
    updateDate: function(){
        var timeZoneText = this.state.timeZoneText;
        if (timeZoneText == "") {
            timeZoneText = $("#dateTimezone option:selected").text();
        }
        var tzOffset = this.state.timeZoneString;
        if (tzOffset.indexOf("-") < 0){
            tzOffset = "+" + tzOffset;
        }
        newDate = new Date(this.state.dateString + " " + this.state.hourString + ":" + this.state.minuteString + " " + this.state.ampmString + " " + tzOffset);
        this.setState(
            {
                date: newDate.getTime(),
                timeZoneText: timeZoneText,
                isDst: this.checkIfDST(newDate)
            },
            this.props.onChange);
    },
    componentDidUpdate: function(prevProps, prevState) {
        
    },
    getDateString: function(dateObj) {
        
        var days = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
        var months = new Array("January", "February", "March","April", "May", "June", "July","August", "September", "October","November", "December");

        var day = days[dateObj.getDay()];
        var month = months[dateObj.getMonth()];
        var date = dateObj.getDate();
        var year = dateObj.getFullYear();

        return day + ", " + month + " " + date + ", " + year;
    },
    getDateValueString: function(dateObj) {
        return (dateObj.getMonth() +1) + "/" + dateObj.getDate() + "/" + dateObj.getFullYear();
    },
    getDates: function(){
        var dateList = new Array();
        var maxDays = this.props.maxDays;
        for (i=0;i<maxDays;i++) {
            var newDate = new Date();
            newDate.setDate(newDate.getDate() + i);
            dateList.push( <option key={i} value={this.getDateValueString(newDate)}>{this.getDateString(newDate)}</option> );
        }

        return dateList;
    },
    checkIfDST: function(date) {
        return date.getTimezoneOffset() < this.stdTimezoneOffset();
    },
    getTimeZones: function(){
        var timeZones = new Array();
        var standardUSZones = ["SAMT","MSK","EET","CET","GMT","AST","EST","CST","MST","PST","AKST","HAST"];
        var standardUSOffsets = ["400","300","200","100","000","-400","-500","-600","-700","-800","-900","-1000"];
        var daylightUSZones = ["MSD","EEST","CEST","BST","GMT","ADT","EDT","CDT","MDT","PDT","AKDT","HADT"];
        var daylightUSOffsets = ["400","300","200","100","000","-300","-400","-500","-600","-700","-800","-900"];;

        var isDst = this.state.isDst; 

        for (i=0;i<standardUSZones.length;i++){

            var value;
            var display;

            if (isDst){
                value = daylightUSOffsets[i];
                display = daylightUSZones[i];
            } else {
                value = standardUSOffsets[i];
                display = standardUSZones[i];
            }

            timeZones.push(<option key={i} value={value} >{display}</option>)
        }

        return timeZones;
    },
    stdTimezoneOffset: function() {
        var now = new Date();
        var jan = new Date(now.getFullYear(), 0, 1);
        var jul = new Date(now.getFullYear(), 6, 1);
        return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
    },
    handleDateChange: function(event){
        this.setState({dateString: event.target.value},this.updateDate);
    },
{'fraction_non_alphanumeric': 0.16654833147378031, 'fraction_numerical': 0.024546100010143016, 'mean_word_length': 2.04508956145769, 'pattern_counts': {'":': 4, '<': 27, '<?xml version=': 0, '>': 23, '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': '1551907', 'n_tokens_mistral': 3236, 'n_tokens_neox': 2941, 'n_words': 595}