GithubHelp home page GithubHelp logo

phn / jdcal Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 17.0 61 KB

Julian dates, stored as two numbers, from proleptic Gregorian and Julian calendars.

License: BSD 2-Clause "Simplified" License

Python 100.00%

jdcal's People

Contributors

avalentino avatar coop56 avatar hugovk avatar jdufresne avatar kishorkunal-raj avatar mattjmorrison avatar medecau avatar phn avatar thenordine avatar zed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jdcal's Issues

Return minus number when JD less than -65965

jd2gcal() will return invalid date in minus number when JD less than -68964

>>> jd2gcal(0, -68964)
(-4901, 2, 1, 0.5)
>>> jd2gcal(0, -68965)
(-4901, 2, 0, 0.5)
>>> jd2gcal(0, -68966)
(-4901, 2, -1, 0.5)

more example:

>>> jd2gcal(0, -100010)
(-4986, 2, 1, 0.5)
>>> jd2gcal(0, -100011)
(-4986, 2, 0, 0.5)
>>> jd2gcal(0, -100012)
(-4986, 2, -1, 0.5)
>>> jd2gcal(0, -100041)
(-4986, 2, -30, 0.5)
>>> jd2gcal(0, -100042)
(-4986, 1, -1, 0.5)

pip install jdcal==1.0 fails

Hello,

After jdcal version 1.0.1 appeared I can't install jdcal version 1.0 anymore using pip:

$ pip install jdcal==1.0
Collecting jdcal==1.0
  Could not find a version that satisfies the requirement jdcal==1.0 (from versions: 1.0.1)
No matching distribution found for jdcal==1.0

Is it possible to also keep jdcal version 1.0 on the pypi?

Nice examples

But you left out one import't thing. That's right mate.
What the bloody l do we import for sure?
import jdcal
gives me no worries but then something like
gcal2jd(2000,1,1)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'gcal2jd' is not defined

So nice to 'ave things so well documented ah gov?
So I did find that
jdcal.gcal2jd(2000,1,1)
(2400000.5, 51544.0)
does it's best.

I'm still new to Python and didn't quite know how to import it.
Could you update your webpage about it?
I discovered this in my recent learning:
from jdcal import *
seems to do the trick.
Just for the sake of newbs?

[refactoring]: jd2gcal

I would suggest to refactor jd2gcal. See mjd2date(mjd) below:

$ pip install jdcal
$ ./test_jdcal.py
 passed
$ cat test_jdcal.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
from jdcal import jd2gcal

def test():
    for mjd in range(146097):
        w = {jd2gcal: jd2gcal(2400000.5, mjd)[:3], mjd2date: mjd2date(mjd)}
        if w['jd2gcal']!=w['mjd2date']:
            print(w['jd2gcal'], "!=", w['mjd2date'])
            return
    print(' passed')

# conversion from modified Julian date to Gregorian calendar date 
def mjd2date(mjd):
    n = mjd + 678881  # Gregorian
    a = 4*n + 3
    a += 4*((3*((4*(n+1))//146097+1))//4)  # Gregorian
    b = 5*((a%1461)//4) + 2
    year, month, day = a//1461, b//153 + 3, (b%153)//5 + 1
    if month > 12:
        year, month = year+1, month%12
    return year, month, day

test()

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.