<commit_before>'use strict'

module.exports = function (req, res) {
    var timestamp = {
        unix: null,
        natural: null
    };
    
    var param = req.url.substring(1);
    var num = Number(param);
    
    if ((num || num === 0) && Number.isSafeInteger(num)) {
        var date = new Date(num);
        var str = month[date.getUTCMonth()] + " " + date.getUTCDate() + ", " + date.getUTCFullYear();
        timestamp.unix = date.valueOf();
        timestamp.natural = str;
    }
    
    res.json(timestamp);
};

var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];<commit_msg>send json for natural language date<commit_after>'use strict';

module.exports = function (req, res) {
    var timestamp = {
        unix: null,
        natural: null
    };
    
    var param = decodeURIComponent(req.url.substring(1));
    var num = Number(param);
    var re = /^([a-z]+) ([0-9]+), ([0-9]+)$/i;
    
    if ((num || num === 0) && Number.isSafeInteger(num)) {
        var date = new Date(num);
        var str = month[date.getUTCMonth()] + " " + date.getUTCDate() + ", " + date.getUTCFullYear();
        timestamp.unix = date.valueOf();
        timestamp.natural = str;
    } else if (re.test(param)) {
        var date = new Date(0);
        var array = re.exec(param);
        var monthVal = monthToInt(array[1]);
        if(monthVal !== -1) {
            date.setUTCFullYear(array[3], monthVal, array[2]);
            var str = month[date.getUTCMonth()] + " " + date.getUTCDate() + ", " + date.getUTCFullYear();
            
            timestamp.unix = date.valueOf();
            timestamp.natural = str;
        }
    };
    
    res.json(timestamp);
};

var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

function monthToInt (str) {
    for(var i = 0; i < month.length; i++){
        if(str.toUpperCase() == month[i].toUpperCase()) {
            return i;
        }
    }
    return -1;
}
{'fraction_non_alphanumeric': 0.18357487922705315, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 2.3950819672131147, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '5702759', 'n_tokens_mistral': 694, 'n_tokens_neox': 678, 'n_words': 153}