?? ttime.cpp
字號(hào):
#include <e32base.h>
#include <e32cons.h>
_LIT(KTxtExampleCode,"時(shí)間演示");
LOCAL_D CConsoleBase* console;
//執(zhí)行例子程序
LOCAL_C void callExampleL();
LOCAL_D TInt error;
LOCAL_C void Exit();
//主函數(shù)
GLDEF_C TInt E32Main()
{
__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New();
TRAP(error,callExampleL());
__ASSERT_ALWAYS(!error,User::Panic(_L("Error Exit"),error));
delete cleanup;
__UHEAP_MARKEND;
return 0;
}
LOCAL_C void callExampleL()
{
console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
CleanupStack::PushL(console);
//TTime* myTime=new TTime();
console->Printf(_L("PressKey...\n"));
TInt i=0;
TInt key=-1;
do
{
key=console->Getch();
console->Printf(_L("[%C]\n"),key);
if(key==99)
{
console->ClearScreen();
}
//TDateTime 示例代碼
if(key==49)
{
console->SetTitle(_L("TDateTime Demo"));
// TDateTime 可以有兩個(gè)構(gòu)造函數(shù),帶參數(shù)和不帶參數(shù);
TDateTime dtm_1;
TDateTime* dtm_2=new TDateTime(1996,ENovember,5,00,00,00,000000);
TDateTime* dtm_3=new TDateTime();
//定義以后,可以對(duì)日期進(jìn)行設(shè)置
dtm_1.Set(2005,EOctober,8,23,40,43,145654);
//也可以單獨(dú)設(shè)置,如:
dtm_2->SetYear(2004);
//輸出時(shí)間
console->Printf(_L("%d年"),dtm_1.Year());
console->Printf(_L("%d月"),dtm_1.Month());
console->Printf(_L("%d日\n"),dtm_1.Day());
console->Printf(_L("%d:"),dtm_1.Hour());
console->Printf(_L("%d:"),dtm_1.Minute());
console->Printf(_L("%d\n"),dtm_1.Second());
//dtm_3 沒有初始化
console->Printf(_L("%d年"),dtm_3->Year());
console->Printf(_L("%d月"),dtm_3->Month());
console->Printf(_L("%d日\n"),dtm_3->Day());
console->Printf(_L("%d:"),dtm_3->Hour());
console->Printf(_L("%d:"),dtm_3->Minute());
console->Printf(_L("%d\n"),dtm_3->Second());
}
// TTime 示例代碼
if(key==50)
{
console->SetTitle(_L("TTime Demo"));
TTime ttm_1;
TTime* ttm_2=new TTime(_L("20050309:125825."));
_LIT(MyTmStr,"20640102:");
ttm_1.Set(MyTmStr);
// 獲取當(dāng)前系統(tǒng)時(shí)間
ttm_2->HomeTime();
//ttm_2+=2;
TDateTime tdm=ttm_2->DateTime();
//輸出時(shí)間
console->Printf(_L("%d年"),tdm.Year());
console->Printf(_L("%d月"),(1+tdm.Month()));
console->Printf(_L("%d日\n"),(1+tdm.Day()));
console->Printf(_L("%d:"),tdm.Hour());
console->Printf(_L("%d:"),tdm.Minute());
console->Printf(_L("%d\n"),tdm.Second());
}
if(key==27)
{
console->Write(_L("EndProgram...\n"));
User::Panic(_L("Normal Exit"),3302);
}
i++;
}while(i<1000);
CleanupStack::PopAndDestroy();
}
//結(jié)束程序
LOCAL_C void Exit()
{
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -