/**
 * Created by apizzimenti on 1/1/17.
 */

var Error = require("./Error").Error,
    
    chalk = require("chalk");

function paramExist (param, type) {
    return (typeof(param) == type && param !== undefined && param !== null);
}

function Location (location) {
    
    if (paramExist(location, "object")) {
        apply(location, this);
    }
}

function Weather (w) {
    
    if (paramExist(w, "object")) {
        apply(w, this);
    }
}

function apply (give, receive) {
    
    for (var prop in give) {
        if (give.hasOwnProperty(prop)) {
            receive[prop] = give[prop];
        }
    }
}

function realTime (timestring) {
    
    var date = new Date(timestring * 1000),
        hours = date.getHours(),
        minutes = date.getMinutes(),
        suffix = "";
    
    suffix = hours > 12 ? "pm" : "am";
    hours = hours > 12 ? hours - 12 : hours;
    minutes = minutes > 10 ? minutes : "0" + minutes;
    
    return hours + ":" + minutes + suffix;
}

function hotCold (temp, units) {
    
    var t,
        e = new Error();
    
    if (paramExist(temp, "number")) {
        t = units ? 0 : 32;
        return (temp > t ? chalk.red(temp) : chalk.blue(temp));
    }
    
    e.message = "The temperature parameter does not exist.";
    e.throw();
}

function tableContent (content) {
    
    return {
        content: content,
        hAlign: "center"
    };
}


module.exports = {
    paramExist: paramExist,
    Location: Location,
    Weather: Weather,
    realTime: realTime,
    hotCold: hotCold,
    tableContent: tableContent
};

@@ -639,20 +639,32 @@
 mestring
+, includeDay
 ) %7B%0A
-
     %0A   
@@ -770,24 +770,66 @@
 tMinutes(),%0A
+        month = null,%0A        day = null,%0A
         suff
@@ -989,22 +989,1334 @@
    %0A    
-return
+if (includeDay) %7B%0A        %0A        switch(date.getMonth()) %7B%0A            %0A            case 0:%0A                month = %22January%22;%0A                break;%0A                %0A            case 1:%0A                month = %22February%22;%0A                break;%0A                %0A            case 2:%0A                month = %22March%22;%0A                break;%0A                %0A            case 3:%0A                month = %22April%22;%0A                break;%0A                %0A            case 4:%0A                month = %22May%22;%0A                break;%0A                %0A            case 5:%0A                month = %22June%22;%0A                break;%0A                %0A            case 6:%0A                month = %22July%22;%0A                break;%0A                %0A            case 7:%0A                month = %22August%22;%0A                break;%0A            %0A            case 8:%0A                month = %22September%22;%0A                break;%0A                %0A            case 9:%0A                month = %22October%22;%0A                break;%0A                %0A            case 10:%0A                month = %22November%22;%0A                break;%0A                %0A            case 11:%0A                month = %22December%22;%0A                break;%0A        %7D%0A        %0A        day = date.getDay();%0A        %0A    %7D%0A    %0A    return (month ? month  + %22 %22 : %22%22) + (day ? day + %22 %22 : %22%22) +
  hours +

add full date options