I need help understanding julian dates.
I am trying to create a program using julian dates where user enters month & year and show the calendar of that month.
I especially don't understand the "int toJulian()"...

here is what I have so far:

#include <stdio.h>
#define START 1900 //fixed year

//PROTOTYPES here

void main(void)
{
	int day, month, year, startDay, numDays;
	numDays = 0;
	startDay = 1;
	day = 0;
	getMonthYear(&month, &year);
	toJulian(month, day, year);
	yearsToDays(year);
	printCalendar(startDay, numDays);
}
void getMonthYear(int *month, int *year)
{
	printf("Enter month: ");
	scanf_s("%d", month);
	printf("Enter year: ");
	scanf_s("%d", year);
	printf("\n"); 

}
int toJulian(int month, int day, int year) //takes calendar date and calculates its julian day within the year
{
	int count;
	for(count = 1; count < month; ++count)
		day =+ daysInMonth(month, year);
	
}
int daysInMonth(int month, int year) //takes a month and year and calculates how many days are in this particular month
{
	int numDays;
	if (month == 1)
		numDays = 31;
	else if (month == 2)
		numDays = 28 + leapYear(year);
	else if (month == 3)
		numDays = 31;
	else if (month == 4)
		numDays = 30;
	else if (month == 5)
		numDays = 31;
	else if (month == 6)
		numDays = 30;
	else if (month == 7)
		numDays = 31;
	else if (month == 8)
		numDays = 31;
	else if (month == 9)
		numDays = 30;
	else if (month == 10)
		numDays = 31;
	else if (month == 11)
		numDays = 30;
	else if (month == 12)
		numDays = 31;
}
int leapYear(int year) //takes year and returns 1 if leap year otherwise 0
{
	if (year % 400 == 0)
		return 1;
	else 
		return 0;
}
long yearsToDays(int year) // takes year returns the number of days from 1/1/1900 to end of previous year.
{
	int count;
	long days;
	for(count = START; count < year; ++count)
		days = 365 + leapYear(year);
}
void printCalendar(int startDay, int numDays)
{
	int num, dayid;
	printHeader();

}
void printHeader()
{
	printf("SUN MON TUE WED THU FRI SAT\n");
}

julian dates is just a count of the number of days from 1 January to the current day of year. And that's all toJulian() is doing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.