#define	DEBUG	0
/* 
	TOWNS囲碁棋譜記録プログラム gadget.c
	                                      1992/05/05  久保田俊也

*/
#include <stdio.h>
#include <time.h>
#include "igo.h"
#include "banx.h"
#include "kiffile.h"
#include "title.h"

int hyouji_start_end_time( char *disp_line, char *disp_line2)
{
char wstr[33];
YMDHM *start_time;
YMDHM *end_time;

	start_time = title_playstart_time_read();
	end_time = title_playend_time_read();

/*
	sprintf( disp_line, "%2d年%2d月%2d日%2d時%2d分",
				start_time->year, start_time->month, start_time->day,
				start_time->hour, start_time->minute);
 */	

	disp_line[0] = '\0';
	disp_line2[0] = '\0';
	if( start_time->year == 0){
		goto starttime_end;
	}
	
	strcpy( disp_line, _itoa( start_time->year, wstr, 10));
	strcat( disp_line, "年");
	
	if( start_time->month == 0){
		goto starttime_end;
	}
	
	strcat( disp_line, _itoa( start_time->month, wstr, 10));
	strcat( disp_line, "月");
	
	if( start_time->day == 0){
		goto starttime_end;
	}
	
	strcat( disp_line, _itoa( start_time->day, wstr, 10));
	strcat( disp_line, "日");
	
	if( start_time->hour==0 && start_time->minute == 0 && 
		end_time->hour==0 && end_time->minute == 0){
		;
	}else{
		strcat( disp_line, _itoa( start_time->hour, wstr, 10));
		strcat( disp_line, "時");
	
		strcat( disp_line, _itoa( start_time->minute, wstr, 10));
		strcat( disp_line, "分");
	}

starttime_end:

	
	if( end_time->year != 0){
		strcpy( disp_line2, _itoa( end_time->year, wstr, 10));
		strcat( disp_line2, "年");
	}else{
		strcpy( disp_line2, "      ");
	}

	if( end_time->month != 0){
		strcat( disp_line2, _itoa( end_time->month, wstr, 10));
		strcat( disp_line2, "月");
	}else{
		/* 省略時の長さの調整 */
		if( start_time->month < 10){
			strcat( disp_line2, "   ");
		}else{
			strcat( disp_line2, "    ");
		}
	}

	if( end_time->day != 0){
		strcat( disp_line2, _itoa( end_time->day, wstr, 10));
		strcat( disp_line2, "日");
	}else{
		/* 省略時の長さの調整 */
		if( start_time->day < 10){
			strcat( disp_line2, "   ");
		}else{
			strcat( disp_line2, "    ");
		}
	}

	if( end_time->hour != 0 || end_time->minute != 0){
		strcat( disp_line2, _itoa( end_time->hour, wstr, 10));
		strcat( disp_line2, "時");
		strcat( disp_line2, _itoa( end_time->minute, wstr, 10));
		strcat( disp_line2, "分");
	}

	/* ０分の入力は省略型とはみなさない　*/

	return 0;

}

