Giter Site home page Giter Site logo

Wrong values in years B.C. about ephemeris HOT 6 CLOSED

mivion avatar mivion commented on June 12, 2024
Wrong values in years B.C.

from ephemeris.

Comments (6)

mivion avatar mivion commented on June 12, 2024

Hi,

Thanks, this is a bug.

from ephemeris.

blucobalto avatar blucobalto commented on June 12, 2024

Hi,
below the "$ ns.julian.calc" changed that solves the bug of Julian date.
I hope.

Thanks a lot,
blu

$ns.julian.calc = function (date) {
    var centuries;
    var year;
    var month;
    var b = 0;
    var c;
    var e;

    /* The origin should be chosen to be a century year
     * that is also a leap year.  We pick 4801 B.C.
     */
    year = date.year + 4800;
    if (date.year < 0) {
        year += 1;
    }

    /* The following magic arithmetic calculates a sequence
     * whose successive terms differ by the correct number of
     * days per calendar month.  It starts at 122 = March; January
     * and February come after December.
     */
    month = date.month;
    if (month <= 2) {
        month += 12;
        year -= 1;
    }
    e = Math.floor ((306 * (month + 1)) / 10);

    // number of centuries
    centuries = Math.floor (year / 100);

    if (date.year <= 1582) {
        if (date.year == 1582) {
            if (date.month < 10) {
                b = -38;
            }
            if (date.month > 10 || date.day >= 15) {
                // number of century years that are not leap years
                b = Math.floor ((centuries / 4) - centuries);
            }
        }
        else { b = -38; } //**** additional line to fix the bug *****
    } else {
        b = Math.floor ((centuries / 4) - centuries);
    }

    // Julian calendar years and leap years
    c = Math.floor ((36525 * year) / 100);

    /* Add up these terms, plus offset from J 0 to 1 Jan 4801 B.C.
     * Also fudge for the 122 days from the month algorithm.
     */
    date.julianDate = b + c + e + date.day - 32167.5;

    // Add time
    date.julianTime = (3600.0 * date.hours + 60.0 * date.minutes + date.seconds) / 86400.0;

    date.julian = date.julianDate + date.julianTime;

    date.j2000 = 2000.0 + (date.julian - $const.j2000) / 365.25;
    date.b1950 = 1950.0 + (date.julian - $const.b1950) / 365.25;
    date.j1900 = 1900.0 + (date.julian - $const.j1900) / 365.25;

    return date.julian;
};

from ephemeris.

blucobalto avatar blucobalto commented on June 12, 2024

Sorry I had closed the bug by accident.

blu

from ephemeris.

mivion avatar mivion commented on June 12, 2024

Hi!

Could you make a pull request?

from ephemeris.

blucobalto avatar blucobalto commented on June 12, 2024

OK done.

from ephemeris.

mivion avatar mivion commented on June 12, 2024

Merged.

from ephemeris.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.