add numerical recipes library
This commit is contained in:
27
lib/nr/k_and_r/recipes/julday.c
Normal file
27
lib/nr/k_and_r/recipes/julday.c
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#include <math.h>
|
||||
#define IGREG (15+31L*(10+12L*1582))
|
||||
|
||||
long julday(mm,id,iyyy)
|
||||
int id,iyyy,mm;
|
||||
{
|
||||
void nrerror();
|
||||
long jul;
|
||||
int ja,jy=iyyy,jm;
|
||||
|
||||
if (jy == 0) nrerror("julday: there is no year zero.");
|
||||
if (jy < 0) ++jy;
|
||||
if (mm > 2) {
|
||||
jm=mm+1;
|
||||
} else {
|
||||
--jy;
|
||||
jm=mm+13;
|
||||
}
|
||||
jul = (long) (floor(365.25*jy)+floor(30.6001*jm)+id+1720995);
|
||||
if (id+31L*(mm+12L*iyyy) >= IGREG) {
|
||||
ja=(int)(0.01*jy);
|
||||
jul += 2-ja+(int) (0.25*ja);
|
||||
}
|
||||
return jul;
|
||||
}
|
||||
#undef IGREG
|
||||
Reference in New Issue
Block a user