nouvelle fonction po
by toubia95
JavaScript
var gnjs = gnjs || (function () {
"use strict";
// Private Constants
var _c = {
VERSION: "0.1.0",
AUTHOR: "Gilles Toubiana"
};
// Public Constants
var c = {
m: [" janvier ", " février ", " mars ", " avril ", " mai ", " juin ", " juillet ", " août ", " septembre ", " octobre ", " novembre ", " décembre "]
};
// Functions (Public functions are declared at the end)
var d = function (dd, mm, yyyy) { // Date object
var odate;
if ((isFinite(parseInt(dd, 10))) && (isFinite(parseInt(mm, 10))) && (isFinite(parseInt(yyyy, 10)))) {
odate = new Date(yyyy, mm - 1, dd);
} else {
throw new Error("Mauvais arguments dans gnjs.d : utilisez des nombres !");
}
return odate;
};
var df = function (d, sep) { // Date Format
var fdate;
if (d instanceof Date) {
if (sep === undefined) {
fdate = d.getDate() + this.c.m[d.getMonth()] + (d.getYear() + 1900);
} else {
fdate = d.getDate() + sep + (d.getMonth() + 1) + sep + (d.getYear() + 1900);
}
} else {
throw new Error("Mauvais arguments dans gnjs.df: utilisez un objet gnjs.d et un caractère de séparation !");
}
return fdate;
};
var a = function (d, age) { // Acte
var birth = {};
if ((d instanceof Date) && (isFinite(parseInt(age, 10)))) {
birth = {
"s": new Date(((d.getYear()) - 1) - age, (d.getMonth()), (d.getDate()) + 1),
"e": new Date(((d.getYear()) + 1) - age, (d.getMonth()), (d.getDate()) - 1),
"y": (d.getYear() + 1900) - age
};
} else {
throw new Error("Mauvais arguments dans gnjs.a: utilisez un objet gnjs.d et un age en chiffres !");
}
return birth;
};
var p = function (s, e) { // Period
var temp, njours = {};
if ((s...