All pastes #342115 Raw Edit

Someone

public cpp v1 · immutable
·published 2007-02-06 02:47 UTC
rendered paste body
#include <stdio.h>#include <math.h>#include <stdlib.h>double floor(double arg); //protoint main(int argc , char *argv[]){  //  printf("%d",argc);  if(argc!=4){   printf("Expected 3 arguments : year month day  \n");   exit(-1);  }    int year=atoi(argv[1]),month=atoi(argv[2]),day=atoi(argv[3]);  const int JGREG=15+31*(10+12*1582);  int julianYear = year;  if(year<0)julianYear++;  int julianMonth=month;  if(month>2)    julianMonth++;  else{    julianYear--;    julianMonth+=13;  } double julian = (floor(365.25 * julianYear)+ floor(30.6001*julianMonth) + day + 1720995.0);  if(day+31*(month+12*year)>=JGREG){    int ja=(int)(0.01*julianYear);    julian += 2-ja+(.25*ja);  }  printf("Julian date is %f\n",julian);     return 0;}