Manipulation des dates

by toubia95

JavaScript

var gnjs = (function() {
    "use strict";

    // Private Constants
    /*
    var Private_Constants = {
        V: "0.1.0", //VERSION
        A: "Gilles Toubiana" //AUTHOR
    },
    */

    // Public Constants (Public constants are declared in the return block, at the end)    
    var Public_Constants = {
        m: [" janvier ", " février ", " mars ", " avril ", " mai ", " juin ", " juillet ", " août ", " septembre ", " octobre ", " novembre ", " décembre "]
    },

        // All Functions (Public functions are declared in the return block, at the end)
        d = function(dd, mm, yyyy) { // Date Object
            return new Date(yyyy, mm - 1, dd);
        },

        df = function(d, sep) { // Date Format
            if (d instanceof Date) {
                return (sep === undefined) ? d.getDate() + Public_Constants.m[d.getMonth()] + (d.getYear() + 1900) : d.getDate() + sep + (d.getMonth() + 1) + sep + (d.getYear() + 1900);
            }
        },

        a = function(d, age) { // Acte Object
            if ((d instanceof Date) && (isFinite(parseInt(age, 10)))) {
                return {
                    "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": parseInt(((d.getYear() + 1900) - age), 10)
                };
            }
        },

        p = function(s, e) { // Period Object
            if ((s instanceof Date) && (e instanceof Date)) {
                return {
                    "s": (s > e) ? e : s,
                    "e": (s > e) ? s : e,
                    "l": Math.round(Math.abs((e - s) / (1000 * 60 * 60 * 24)) + 1)
                };
            }
        },

        po = function(p1, p2) { // Periods Overlap
            var overlap, min, max;
            if (p1 && p2 && (p1.s instanceof Date) && (p1.e instanceof Date) && (p2.s instanceof Date) && (p2.e instanceof Date)) {
             ...