C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[13002] Re:Re:[질문] TDateTime형에 대하여.
아리랑 [] 1159 읽음    2001-11-22 22:31
답변하신님 제 질문의 의도를 잘못아셨군요. 내용이 꼬였나봅니다.
  FormatDateTime("yyyy/mm/dd", Now())에서 Now()가 아니라 제가 원하는 날자를 가진 TDate형 생성시킬때
문제를 말한거였습니다. 이미 생성된 TDate형을 포멧팅하는게 아니였습니다.

Creates and initializes an instance of TDateTime.

__fastcall TDateTime(unsigned short year, unsigned short month, unsigned short day);

Description

Use TDateTime to instantiate a TDateTime object.

When called with three unsigned shorts (as the year, month, and day parameters), the resulting object뭩 value is assembled from the specified year, month, and day, with a time portion of 0 (midnight). The year must be between 1 and 9999. Valid month values are 1 through 12. Valid day values are 1 through 28, 29, 30, or 31, depending on the month value. For example, the possible day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the year value specifies a leap year.

TDateTime형의 도움말에 나오는 내용입니다. 그런데 이게 이대로 돌지 않는다는 뜻이죠.

그리고 두번째문제도 DB관련문제가 아니라 TDateTime형과 time_t형과의 변환문제 입니다.
하여튼 관심 가져주셔서 감사드립니다.


우쒸 님이 쓰신 글 :
: 아리랑 님이 쓰신 글 :
: : 게시판에 질문으로 도배를 해서 죄송합니다.
: :
: : 빌더 5.0에서 두가지 질문입니다.
: :
: :   1. 빌더에서 TDate(년도,월,일)로 생성하니 에러가 납니다. 추적에 들어가보면 TDate dDate(1998,1,1)로 생성하면 vcl소스에서 보면 년도,월,일 등에 전부 쓰레기 값이 들어가 있더군요. 원래 이런건지..
: : 그래서 TDate dDate = StrToDate(IntToStr(tmt->tm_year + 1900)+"-"+IntToStr(tmt->tm_mon+1)+"-"+IntToStr(tmt->tm_mday)); 이렇게 생성합니다.
:
:
:
:
:
: TDateTime Class 를 사용하여서 FormatDateTime("yyyy/mm/dd", Now()) 이런식으로 년도타입을 맞춰주세요
: 2번질문..전 DB를 몰라서..ㅋㄷㅋㄷ bye
:
:
:
: :
: :   2. 제가 Mysql DB하나로 gcc,php,vc++,builder등에서 제각기 Access해야 하므로 날짜와 시간을 Unix의 time_t값으로 저장해서 사용합니다. 물론 DB에서 제공하는 기본 Date형을 사용할 수도 있지만 그렇게 되면 gcc에서 이 값을 가지고 연산, 처리하는게 좀 복잡해서요. -- 할줄 몰라서 그럴수도 --
: :   TDateTime 형에서 time_t형으로 바로 변환해 주는건 없는지요? 아무리 뒤져봐도 없어서 아래와 같이 사용합니다.
: :
: : // time_t의 값을 TDateTime형으로 변환
: : TDateTime time_tToDate(time_t CvtTime)
: : {
: :     struct tm *tmt = localtime(&CvtTime);
: :     if(CvtTime <= 0) return TDateTime();
: :     TDate dDate = StrToDate(IntToStr(tmt->tm_year + 1900)+"-"+IntToStr(tmt->tm_mon+1)+"-"+IntToStr(tmt->tm_mday));
: :     return dDate;
: : }
: :
: : // TDateTime형을 time_t형으로 변환
: : time_t DateTotime_t(TDateTime nDate )
: : {
: :     Word nYear,nMon,nDay,nHour = 0,nMin = 0,nSec = 0,nmSec = 0;
: :     struct tm tmt;
: :     DecodeDate(nDate,nYear,nMon,nDay);
: :     DecodeTime(nDate,nHour,nMin,nSec,nmSec);
: :     tmt.tm_year     = nYear - 1900;
: :     tmt.tm_mon      = nMon - 1;
: :     tmt.tm_mday     = nDay;
: :     tmt.tm_hour     = nHour;
: :     tmt.tm_min      = nMin;
: :     tmt.tm_sec      = nSec;
: :     tmt.tm_wday     = nDate.DayOfWeek() - 1;
: :     tmt.tm_isdst    = 0;
: :     return mktime(&tmt);
: : }
: :
: :
: :
: :
: :
: :

+ -

관련 글 리스트
12979 [질문] TDateTime형에 대하여. 아리랑 1052 2001/11/22
12989     Re:[질문] TDateTime형에 대하여. 우쒸 1160 2001/11/22
13002         Re:Re:[질문] TDateTime형에 대하여. 아리랑 1159 2001/11/22
13018             Re:Re:Re:[질문] TDateTime형에 대하여. 우쒸 1288 2001/11/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.