/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
FILE		: Time.js
URL			: 
Author      : Tae.Ki.Kim
Version     : TimeScript 1.0.0
creation    : 2005. 10. 28

Description :
	1. getNow(type)
	Type¿¡ µû¶ó¼­ ÇöÀç ½Ã°£À» ¸®ÅÏÇÑ´Ù.
		 1) D - 2003-11-20
         2) T - 18:11:23
         3) A - 2003-11-20 18:11:23

	2. getNowString(type)
	Type¿¡ µû¶ó¼­ ÇöÀç ½Ã°£À» ½ºÆ®¸µ ÇüÅÂ·Î ¸®ÅÏÇÑ´Ù.
		 1) D - 2003-11-20
         2) T - 18:11:23
         3) A - 2003-11-20 18:11:23

	
	»ç¿ë¿¹)

	<script language='javascript' src=Time.js>
	var msg = new Time();
	alert(msg.getNow('D'));
	</script>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
function Time() {
}

Time.prototype.getNow = function (type) {
	return timeGetNow(type);
} 

Time.prototype.getNowString = function (type) {
	return timeGetNowString(type);
} 



function timeGetNow(type){
	var Result = "";
	var now = new Date();
  
	if (type == "D") {
		Result = now.getYear() + "-" + now.getMonth() + "-" + now.getDay();
	}
	else if (type == "T") {
		Result = now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
	} else if (type == "A") {
		Result = now.getYear() + "-" + now.getMonth() + "-" + now.getDay() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
	} 
	return Result;
}

function timeGetNowString(type)
{
	var Result = "";
	var	now = new Date();
	var year  = now.getYear().toString();
	var month = (now.getMonth()+1).toString();
	var date  = now.getDate().toString();
	var hour  = now.getHours().toString();
	var min   = now.getMinutes().toString();
	var sec   = now.getSeconds().toString();

	if(month.length==1)
	{
		month = "0"+month;
	}
	if(date.length==1)
	{
		date = "0"+date;
	}
	if(hour.length ==1)
	{
		hour ="0"+hour;
	}
	if(min.length ==1)
	{
		min ="0"+min;
	}
	if(sec.length ==1)
	{
		sec ="0"+sec;
	}

	 if (type == "D")
	{
		Result = year+month+date;
	}
	else if (type == "T")
	{
		Result = hour+min+sec;
	}
	else  if (type == "A")
	{
		Result =  year+month+date+hour+min+sec;
	}
	
	return Result;
}
