phn / jdcal Goto Github PK
View Code? Open in Web Editor NEWJulian dates, stored as two numbers, from proleptic Gregorian and Julian calendars.
License: BSD 2-Clause "Simplified" License
Julian dates, stored as two numbers, from proleptic Gregorian and Julian calendars.
License: BSD 2-Clause "Simplified" License
Please include LICENSE/COPYING/whatever file with full text of BSD License.
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)
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?
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?
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()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.