bmsjs this current

by toubia95

HTML

<p>BUGS SUR LES JOURS DE LA SEMAINE (dimanche -> samedi)</p>
<p>=== Corrections :</p>
<p>* erreur dans les tableaux (commencaient à lundi plutô que dimanche)</p>
<p>* les jours de la semaine (0-6 ou 1-7) montent jusqu'à 11 pour bms.jour('11/3/2015') => getDay() plutôt que getDate() !!!</p>
<p>===</p>
<p>À corriger :</p>
<p>* intégrer la date julienne dans Jour()</p>

JavaScript

(function (bms, undefined) {
    "use strict";

    /* ===========
     * CONSTANTES
     * =========== */
    bms.constantes = {
        gregorien: {
            F: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
            M: ["janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."],
            l: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
            D: ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."],
            epoch: 1721425.5
        }

    };

    /* ===========
     * UTILITAIRES (fonctions)
     * =========== */

    bms.prefixZero = function (n) {
        return (n < 10) ? "0" + n : n;
    };

    /* ==========
     * JOUR (methode)
     * ========== */

    bms.jour = function (jour) {
        var splitter = jour.split(/\D/);
        this.gregorien = new Date(splitter[2], splitter[1] - 1, splitter[0]);
        this.j = this.gregorien.getDate();
        this.d = this.prefixZero(this.j);
        this.Y = this.gregorien.getFullYear();
        this.y = parseInt(this.Y.toString().substr((this.Y.toString().length) - 2, 2), 10);
        this.w = this.gregorien.getDay();
        this.D = this.constantes.gregorien.D[this.w];
        this.l = this.constantes.gregorien.l[this.w];
        this.N = this.w + 1;
        this.n = this.gregorien.getMonth() + 1;
        this.m = this.prefixZero(this.n);
        this.F = this.constantes.gregorien.F[this.n - 1];
        this.M = this.constantes.gregorien.M[this.n - 1];
        return this;
    };
})(typeof exports === 'undefined' ? this.bms = this.bms || {} : exports);


/* ===========
 * TESTS
 * =========== */

current = bms.jour('12/03/2015');
console.log(current); //56
console.log(current.gregorien); //57
console.log("D - jour de la semaine en texte, version courte = " + current.D); //58
console.log("F - mois en texte, version longue = " + current.F);...