반응형

 

안농

오늘인 비도 춰줙춰줙 내리는 그런날이라 그런지

기분이가 좋군...

 

난 개인적으로 비오는 날씨를 사랑하거든!

오늘은 자주쓰는 개념들 중,

get과 set이라는 애들을 배울건데

 

주거니 받거니 겠지?

주거니 받거니 오고가는 우정속에

싹트는 우리사랑

 

큼흠흠..

사랑을 싹틔우는건 아닌데

기본적인걸 설명하면

 

기존에 있던 기능을 가져와서 사용하는거야

우리 실생활에서도 쓰고있어!

 

간단히 예를들면


 

 

 

( get )

 

A : "야 몇시야?" (get)

b :"웅 지금 9시 30분임 ㅇㅇ"(set)

A : "아 9시 30분이구나"(get)

 

이런거지


( set)

 

A : "야 저거 시간 5분 느린거임 ㅇㅇ"

B : " 아 구뤠? 알았음 "

C : " 몇시임? " ( get ) 

B : "웅 9시 35분임 저거 5분 느린거랬음 ㅇㅇ"

 

 


차이를 알겠어?

 

get은 기존에 있던걸 가져와서 쓰는거고

set은 기존에 있던것에 값을 주어 사용하는거야

그 중 오늘은 get에 관한 친구들을 알아볼게!

 


< 코드 >

 

<script type="text/javascript">
//<![CDATA[
	
	//Date 객체의 t 변수에 참조
	var t = new Date();

	var nowFullYear 	=	t.getFullYear();
	var nowYear 		= 	t.getYear();
	var nowMonth 		= 	t.getMonth();
	var nowDate			=	t.getDate();
	var nowDay			=	t.getDay();
	var nowHours 		= 	t.getHours();
	var nowMinutes		= 	t.getMinutes();
	var nowSeconds		= 	t.getSeconds();
	var nowMilliseconds	=	t.getMilliseconds();
	var nowTime			=	t.getTime();
	var nowGMTString	=	t.toGMTString();
	
	
	// 월을 조건문으로 처리하기 위한 변수
	var nowMonth_val = "";
	
	// 월을 순 우리말로 처리하는 방법
	var nowMonth_kor_mark = new Array("해오름", "시샘", "물오름", "잎새", "푸른", "누리", "견우직녀", "타오름", "열매", "하늘연", "미틈", "매듭"); 
	
	// 요일을 문자로 변경 첫번째 방법 배열
	var nowDay_kor_mark1 = new Array("일","월","화","수","목","금","토","일");
	
	// 요일을 문자로 변경 두번째 방법 switch (month 도 이런식으로 처리하면 되어서 응용하면 된다이거얌)
	var nowDay_kor_mark2 = "";
	
	var nowDaypp = "";
	
	switch(nowDay){
		case 0 : nowDay_kor_mark2="일";
		break;
		case 1 : nowDay_kor_mark2="월";
		break;
		case 2 : nowDay_kor_mark2="화";
		break;
		case 3 : nowDay_kor_mark2="수";
		break;
		case 4 : nowDay_kor_mark2="목";
		break;
		case 5 : nowDay_kor_mark2="금";
		break;
		case 6 : nowDay_kor_mark2="토";
		break;	
	}
	
	// if 문을 이용해서, month가 0~11의 값일때, 1 추가
	if(nowMonth){
		 nowMonth_val = nowMonth + 1;
	}
	
	// Js에서 제공하는 prototype Property을 활용하는법
	Date.prototype.t = function() {
	  if (this.getDay() == 0){this.nowDaypp = "January"};
	  if (this.getMonth() == 1){this.nowDaypp = "February"};
	  if (this.getMonth() == 2){this.nowDaypp = "March"};
	  if (this.getMonth() == 3){this.nowDaypp = "April"};
	  if (this.getMonth() == 4){this.nowDaypp = "May"};
	  if (this.getMonth() == 5){this.nowDaypp = "June"};
	  if (this.getMonth() == 6){this.nowDaypp = "July"};
	  if (this.getMonth() == 7){this.nowDaypp = "August"};
	  if (this.getMonth() == 8){this.nowDaypp = "September"};
	  if (this.getMonth() == 9){this.nowDaypp = "October"};
	  if (this.getMonth() == 10){this.nowDaypp = "November"};
	  if (this.getMonth() == 11){this.nowDaypp = "December"};
	};
	
	
	document.write("(getFullYear) : " + nowFullYear + "년 <br/>"); 
	// FullYear로 하면 4자리의 연도가 나옴
	
	document.write("(getYear) : " + nowYear + "년 <br/><br/>"); 
	// 1900년을 뺀 숫자를 return함! FullYear 사용 권장
	
	document.write("(getMonth) : " + nowMonth + "월 (원표기) <br/>"); 
	// 0~11, 1월~12월 이렇게 볼 수 있음..!
	
	document.write("(getMonth) : " + nowMonth_kor_mark[nowMonth] + "달 (배열활용) <br/>"); 
	// 0~11, 1월~12월 이렇게 볼 수 있음..!
	
	document.write("(getMonth) : " + nowMonth_val + "월 (조건문 활용) <br/>"); 
	// 0~11, 1월~12월 이렇게 볼 수 있음..!
	
	document.write("(getMonth) : " + nowDaypp + "월 (prototype 활용) <br/><br/>"); 
	// prototype활용!!
	
	document.write("(getDate) : " + nowDate + "일 <br/><br/>"); 
	// 일자 표기 1~31일
	
	document.write("(getDay) : " + nowDay + "요일 (원표기) <br/>"); 
	// 원표기 : 0 ~ 6 , 일 ~ 토 이렇게 볼 수 있어!
	
	document.write("(getDay) : " + nowDay_kor_mark1[nowDay] + "요일 (배열활용)<br/>"); 
	// 원표기를 배열을 활용해서 처리
	
	document.write("(getDay) : " + nowDay_kor_mark2 + "요일 (조건문 활용)<br/><br/>") 
	// 원표기를 switch 배열을 활용해서 처리 
	
	document.write("(getHours) : "	+ nowHours +"시 <br/><br/>"); 
	// 24시 표기법
	
	document.write("(getMinites) : "+ nowMinutes +"분 <br/><br/>");
	// 0~59분
	
	document.write("(getSeconds) : "+ nowSeconds +"초 <br/><br/>"); 
	// 0~59초
	
	document.write("(getMilliseconds) : " + nowMilliseconds + "밀리초 <br/><br/>"); 
	// 1/1000초 단위
	
	document.write("(getTime) : " + nowTime + "밀리초 <br/><br/>"); 
	// 1970년 1월 1일에서 부터 현재까지의 초
	
	document.write("(getGMTString) : " + nowGMTString + "<br/><br/>"); 
	// 그리니치 평균시 기준 시간
	
	document.write(	"오늘은 " + nowFullYear + "년 " + nowMonth + "월 " + nowDate + "일 " + nowDay_kor_mark2 + "요일" + nowHours + "시 " + nowMinutes + "분 " + nowSeconds + "초 임 ㅇㅇ. <br/><br/>" );
	
	document.write("다루지 않은 친구들 : getTime, getTimezoneOffset, getUTC~ 친구들. 쓴걸 본적이 거의 없엉 ㅇㅇ");
//]]>
</script>

 

오늘은 조금 길어 : )


< 결과 >

 

 

 

하지만 하나씩 써보다 보면

" 아.. 쉽구먼 그래  끄덕끄덕"

하면서 머리가 슉 하면서 지식이 쌓이는 느낌이들고

 

손맛이 사악~ 돌거야

 

 

이럴거라구 ㅎㅎ

 

오늘은 여기까지! 

 

20000!

반응형