kea-react
Version:
Componentes comunes de react
59 lines (58 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function getEffectiveString(x, string) {
return string == undefined ? cellToText(x) : string;
}
exports.getEffectiveString = getEffectiveString;
/**Convierte una celda en el texto que se va a usar para la busqueda por texto*/
function cellToText(x) {
if (x == null) {
return "";
}
else if (typeof x == "number") {
return "" + x;
}
else if (typeof x == "boolean") {
return x ? "si" : "no";
}
else if (typeof x == "string") {
return x;
}
else if (x instanceof Date) {
return formatDate(x);
}
else if (x instanceof Array) {
var y = x;
return y.map(function (z) { return cellToText(z); }).join(", ");
}
else if (typeof x == "object") {
return Object.keys(x).join(" ");
}
;
throw new Error("No soportado");
}
exports.cellToText = cellToText;
function formatDate(x) {
var locale = "es-MX";
var options;
options = {
year: "numeric",
month: "2-digit",
day: "2-digit",
};
var year = "" + x.getFullYear();
var month = "0" + (x.getMonth() + 1);
var day = "0" + x.getDate();
var hours = "0" + x.getHours();
var minutes = "0" + x.getMinutes();
//True si se debe de mostrar hora y fecha, si no, solo la fecha
var fullDateTime = hours != "00" || minutes != "00";
var dateStr = day.slice(-2) + "/" + month.slice(-2) + "/" + year;
if (fullDateTime) {
var hourStr = hours.slice(-2) + ":" + minutes.slice(-2);
return dateStr + " " + hourStr;
}
else {
return dateStr;
}
}