Exemplo n.º 1
0
void getdate()
{
	char *encodedweekday = getweekday();
    serial_print(toweekday(encodedweekday));
    serial_print(" ");

    char *encodedmonth = getmonth();
    serial_print(tomonth(encodedmonth));
    serial_print(" ");

    serial_print(getmonthday());
    serial_print(" ");

    char *encodedyear = getyear();
    char *year = sys_alloc_mem(5);
    year[0] = '2';
    year[1] = '0';
    year[2] = encodedyear[0];
    year[3] = encodedyear[1];
    year[4] = '\0';
    serial_println(year);
    serial_println("");
    sys_free_mem(encodedyear);
    sys_free_mem(encodedweekday);
    sys_free_mem(encodedmonth);
    sys_free_mem(year);
}
Exemplo n.º 2
0
void print_month_table()
{

	date_cal test_date1,test_date2;

	lunar_month lunar_date;

	int month_lastday;
	int easter_month,easter_day;

	lunar_date=solortolunar(2014,6,27);

    int next_year=year;
    int next_month=month+1;
    if (next_month==13)
    {
    	next_month=1;
    	next_year=next_year+1;
    }

    test_date1.year=next_year;
    test_date1.month=next_month;
    test_date1.day=1;
    test_date1.hour=0;
    test_date1.min=0;

    test_date2=getdatebymin(200,test_date1);

    month_lastday=test_date2.day;

    lunar_date=solortolunar(year,month,1);

    int lmv=0;
    lmonth_info[lmv]=lunar_date.moon;

    test_date1.year=year;
    test_date1.month=month-1;
	if ((month-1)==0)
	{
		test_date1.year=year-1;
		test_date1.month=12;
	}
	test_date1.day=15;
	test_date1.hour=0;
	test_date1.min=0;

	smonth_info[0]=SolortoSo24(test_date1);  //양력1일날의 절기

    test_date1.year=year;
    test_date1.month=month;
    test_date1.day=15;
    test_date1.hour=0;
    test_date1.min=0;
	smonth_info[1]=SolortoSo24(test_date1);  //양력15일날의 절기

    //부활절 계산
	easter_day=0;
	easter_month=0;
	if (year>0)
	{
		test_date1=GetEasterDate(year);

		easter_day=test_date1.day;
		easter_month=test_date1.month;
	}

	int lday=lmonth_info[lmv].moon_next_new.date.day;
	int ingi_day=smonth_info[0].outgi.date.day;

	int dd;
	for(dd=0;dd<month_lastday;dd++)
	{
		int day=dd+1;

		if (day==1)
		{

			day_value[dd][TYPE_Solor_Year]=year; //lunar_info
			day_value[dd][TYPE_Solor_Month]=month; //lunar_info

			day_value[dd][TYPE_Lunar_Year]=lunar_date.lyear; //lunar_info
			day_value[dd][TYPE_Lunar_Month]=lunar_date.lmonth; //lunar_info
			day_value[dd][TYPE_Lunar_Day]=lunar_date.lday; //so24term_month
			if (lunar_date.largemonth) day_value[dd][TYPE_Lunar_largemonth]=1;
			else day_value[dd][TYPE_Lunar_largemonth]=0;
			if (lunar_date.yun_leaf) day_value[dd][TYPE_Lunar_yun_leaf]=1;
			else day_value[dd][TYPE_Lunar_yun_leaf]=0;

			so24_8letter so24_8letter;
			so24_8letter=sydtoso24yd(year,month,1,1,0);

			day_value[dd][TYPE_S60_Year]=so24_8letter.so24year;
			day_value[dd][TYPE_S60_Month]=so24_8letter.so24month;
			day_value[dd][TYPE_S60_Day]=so24_8letter.so24day;

			day_value[dd][TYPE_S_Month_Value]=0;
			day_value[dd][TYPE_L_Month_Value]=lmv;

			day_value[dd][TYPE_Weekday]=getweekday(year,month,1);

			day_value[dd][TYPE_28su_day]=get28sday(year,month,1) ;

			day_value[dd][TYPE_Julian_Date]=getjulianday(year,month,1);


			lday=lmonth_info[lmv].moon_next_new.date.day;
			ingi_day=smonth_info[0].outgi.date.day;
		}
		else
		{
			day_value[dd][TYPE_Weekday]=day_value[dd-1][TYPE_Weekday]+1;
			if (day_value[dd][TYPE_Weekday]==7) day_value[dd][TYPE_Weekday]=0;

			day_value[dd][TYPE_28su_day]=day_value[dd-1][TYPE_28su_day]+1;
			if (day_value[dd][TYPE_28su_day]==28) day_value[dd][TYPE_28su_day]=0;

			day_value[dd][TYPE_Julian_Date]=day_value[dd-1][TYPE_Julian_Date]+1;

			if (day==lday)
			{

				lunar_date=solortolunar(year,month,day);
				lmv=lmv+1;

				lmonth_info[lmv]=lunar_date.moon;


				day_value[dd][TYPE_Lunar_Year]=lunar_date.lyear;
				day_value[dd][TYPE_Lunar_Month]=lunar_date.lmonth; //lunar_info
				day_value[dd][TYPE_Lunar_Day]=lunar_date.lday; //so24term_month

				if (lunar_date.largemonth) day_value[dd][TYPE_Lunar_largemonth]=1;
				else day_value[dd][TYPE_Lunar_largemonth]=0;
				if (lunar_date.yun_leaf) day_value[dd][TYPE_Lunar_yun_leaf]=1;
				else day_value[dd][TYPE_Lunar_yun_leaf]=0;

				day_value[dd][TYPE_L_Month_Value]=lmv;
				lday=lmonth_info[lmv].moon_next_new.date.day;

			}
			else
			{
				day_value[dd][TYPE_Lunar_Year]=day_value[dd-1][TYPE_Lunar_Year];
				day_value[dd][TYPE_Lunar_Month]=day_value[dd-1][TYPE_Lunar_Month];
				day_value[dd][TYPE_Lunar_Day]=day_value[dd-1][TYPE_Lunar_Day]+1;

				day_value[dd][TYPE_Lunar_largemonth]=day_value[dd-1][TYPE_Lunar_largemonth];
				day_value[dd][TYPE_Lunar_yun_leaf]=day_value[dd-1][TYPE_Lunar_yun_leaf];


				day_value[dd][TYPE_L_Month_Value]=day_value[dd-1][TYPE_L_Month_Value];
			}

			if (day==ingi_day)
			{

				day_value[dd][TYPE_S_Month_Value]=1;

				if (smonth_info[1].ingi.name==0)
				{
					day_value[dd][TYPE_S60_Year]=day_value[dd-1][TYPE_S60_Year]+1;
					if (day_value[dd][TYPE_S60_Year]==60) day_value[dd][TYPE_S60_Year]=0;
				}
				else
				{
					day_value[dd][TYPE_S60_Year]=day_value[dd-1][TYPE_S60_Year];
				}

				day_value[dd][TYPE_S60_Month]=day_value[dd-1][TYPE_S60_Month]+1;
				if (day_value[dd][TYPE_S60_Month]==60) day_value[dd][TYPE_S60_Month]=0;

				day_value[dd][TYPE_S60_Day]=day_value[dd-1][TYPE_S60_Day]+1;
				if (day_value[dd][TYPE_S60_Day]==60) day_value[dd][TYPE_S60_Day]=0;

			}
			else
			{
				day_value[dd][TYPE_S60_Year]=day_value[dd-1][TYPE_S60_Year];
				if (day_value[dd][TYPE_S60_Year]==60) day_value[dd][TYPE_S60_Year]=0;

				day_value[dd][TYPE_S60_Month]=day_value[dd-1][TYPE_S60_Month];
				if (day_value[dd][TYPE_S60_Month]==60) day_value[dd][TYPE_S60_Month]=0;

				day_value[dd][TYPE_S60_Day]=day_value[dd-1][TYPE_S60_Day]+1;
				if (day_value[dd][TYPE_S60_Day]==60) day_value[dd][TYPE_S60_Day]=0;

				day_value[dd][TYPE_S_Month_Value]=day_value[dd-1][TYPE_S_Month_Value];
			}


		}
	}


	check_planet_event_month(year,month,timez_off);


	so24_8letter mid_gi_8=sydtoso24yd(smonth_info[1].mingi.date.year,smonth_info[1].mingi.date.month,smonth_info[1].mingi.date.day,smonth_info[1].mingi.date.hour,smonth_info[1].mingi.date.min);


	printf("<table border=1>\n");

	printf("<tr>\n");
	bool date_set=false;

	int day=0;
	int cell;
	for(cell=0;cell<7;cell++)
	{
		printf("<td>");

		if (cell==0)
			printf("<font color=red>");
		else if (cell==6)
			printf("<font color=blue>");
		else
			printf("<font color=black>");

		if (lang==T_English)
			printf("%s",weekday_eng[cell]);
		else
			printf("%s",weekday_kor[cell]);
		printf("</font>");
		printf("</td>");
	}
	printf("</tr>\n");

	int line;
	for(line=1;line<7;line++)
	{
		if ((line==6)&&(date_set==false)) break;
		printf("<tr>\n");
		for (cell=0;cell<7;cell++)
		{

			printf("<td  style=text-align:left;vertical-align:top;padding:0 >\n");

			if ((day==0)&&(day_value[0][TYPE_Weekday]==cell))
			{
				date_set=true;
			}

			if (((line==1)&&(cell==0)&&(date_set==false))||((date_set==false)&&((line==5)||(line==6))&&(cell==6)))
			{

				printf("<font size=5 color=blue>%d",year);
				if (lang==T_English)
				{
					printf("<br>%s<br>%s년<br>%s월",English_month_name[month-1],ganji[mid_gi_8.so24year],ganji[mid_gi_8.so24month]);
				}
				else
				{
					printf("년<br>%d월",month);
					printf("<br>%s년<br>%s월",ganji[mid_gi_8.so24year],ganji[mid_gi_8.so24month]);
				}

				printf("</font>");
			}


			if (date_set)
			{
				day++;

				printf("<font size=\"2\">");
				printf("%s", s28day[day_value[day-1][TYPE_28su_day]]);
				printf("</font>");

				int lunar_hol=-1;

				if ((day_value[day-1][TYPE_Lunar_yun_leaf]==0)
					&&(day_value[day-1][TYPE_Lunar_Month]==1)
					&&(day_value[day-1][TYPE_Lunar_Day]==1)
				   )
				{
					lunar_hol=0;
				}

				if ((day_value[day-1][TYPE_Lunar_yun_leaf]==0)
						&&(day_value[day-1][TYPE_Lunar_Month]==4)
						&&(day_value[day-1][TYPE_Lunar_Day]==8)
					   )
					{
						if (year>-544)
							lunar_hol=1;
					}

				if ((day_value[day-1][TYPE_Lunar_yun_leaf]==0)
						&&(day_value[day-1][TYPE_Lunar_Month]==8)
						&&(day_value[day-1][TYPE_Lunar_Day]==15)
					   )
					{
						lunar_hol=2;
					}

				if ((day==easter_day)&&(month==easter_month))
				{
					if (year>35)
						lunar_hol=3;
				}


				if ((cell==0)||lunar_hol!=-1)
					printf("<font size=6 color=red>");
				else if (cell==6)
					printf("<font size=6 color=blue>");
				else
					printf("<font size=6 color=black>");

				printf("%d", day);
				printf("</font><br>");


				if ((lunar_hol!=-1)&&!((day==easter_day)&&(month==easter_month)))
					printf("<font color=red>");
				else
					printf("<font color=blue>");

				if (lunar_hol==1)
				{
					printf("4.8");
				}
				else
				{
					printf("%d.%d", day_value[day-1][TYPE_Lunar_Month],day_value[day-1][TYPE_Lunar_Day]);
				}
				printf("</font>");


				printf("<font color=black>");

				printf("%s", ganji[day_value[day-1][TYPE_S60_Day]] );
				printf("</font>");

				printf("<br>");

				if (lunar_hol!=-1)
				{
					if (lang==T_English)
						printf("<font color=red>%s</font><br>",st_lunar_freeday_eng[lunar_hol]);
					else
						printf("<font color=red>%s</font><br>",st_lunar_freeday_kr[lunar_hol]);
				}


				int i;

				for (i=0;i<event_result_count;i++)
				{
					date_cal date_temp;

					date_temp=getdatebymin((timez_off+540),planet_event_result_position[i][0].time);

					if ((day==date_temp.day)&&(month==date_temp.month))
					{

						printf("<p><font color=blue size=\"2\">%02d:%02d %s<br>",
									 date_temp.hour,date_temp.min,get_Planet_event_string(i));


						if (lang==T_English)
						{
							printf("%s ",Planet_Orbit[planet_event_result_planet1[i]]->Name_Eng);
						}
						else
						{
							printf("%s ",Planet_Orbit[planet_event_result_planet1[i]]->Name_Kor);
						}

						if (planet_event_result[i]==en_sun_julgi)
						{
				        	if (lang==T_English)
				        		printf(" λ=%2.3f˚", planet_event_result_position[i][planet_event_result_planet1[i]].RAMDA);
				        	else
				        		printf("<br>황경=%2.3f˚", planet_event_result_position[i][planet_event_result_planet1[i]].RAMDA);

						}



				        if (planet_event_result[i]==en_great_elong_east)
				        {
				        	printf("<br>%2.3f˚",
				        			degreelow(planet_event_result_position[i][planet_event_result_planet1[i]].RAMDA - planet_event_result_position[i][planet_event_result_planet2[i]].RAMDA)
				        			);
				        }

				        if (planet_event_result[i]==en_great_elong_west)
				        {
				        	printf("<br>%2.3f˚",
				        			degreelow(planet_event_result_position[i][planet_event_result_planet2[i]].RAMDA - planet_event_result_position[i][planet_event_result_planet1[i]].RAMDA)
				        			);
				        }

						if (planet_event_result[i]==en_planet_conjunction)
						{
							if (lang==T_English)
							{
								printf("%s",Planet_Orbit[planet_event_result_planet2[i]]->Name_Eng);
							}
							else
							{
								printf("%s",Planet_Orbit[planet_event_result_planet2[i]]->Name_Kor);
							}
						}

				        if (
				        		(planet_event_result[i]==en_planet_conjunction)
				        		||(planet_event_result[i]==en_inferior_conjuinction)
				        		||(planet_event_result[i]==en_superior_conjunction)
				        		||(planet_event_result[i]==en_conjunction)
				        	)
				        {
							if (lang==T_English)
							{
								printf(" dβ=");
							}
							else
							{
								printf("<br>황위차이=");
							}

			        		printf("%2.3f˚",
			        				planet_event_result_position[i][planet_event_result_planet1[i]].BETA - planet_event_result_position[i][planet_event_result_planet2[i]].BETA
			            			);
				        }

						printf("</font>");


					}
				}
				double jd=getjuliandate_point_pre(year,month,day,21,0);

				if (jd<2299161)
				{
					date_cal jddate=getjuliandate_from_julianday(jd);
					printf("<br><font size=\"2\">%d-%d<br></font>",jddate.month,jddate.day);
				}


				if (day==month_lastday) date_set=false;
			}



			printf("</td>\n");
		}
		printf("</tr>\n");
	}

	printf("</table><P>\n");

}