本文整理汇总了C++中TDateTime::FormatString方法的典型用法代码示例。如果您正苦于以下问题:C++ TDateTime::FormatString方法的具体用法?C++ TDateTime::FormatString怎么用?C++ TDateTime::FormatString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDateTime
的用法示例。
在下文中一共展示了TDateTime::FormatString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BtnSavePKGDataClick
//---------------------------------------------------------------------------
void __fastcall TFrmUserDataView::BtnSavePKGDataClick(TObject *Sender)
{
BtnSavePKGData->Enabled = false;
BtnInputPKGData->Enabled = true;
UserData_PKG_SaveToSEQ();
UserData_PKG_SaveToDB();
UserData_PKG_ReadFromDB();
UserData_PKG_ReadFromSEQ();
TFileStream *File;
TDateTime dt = Now();
String FolderName = dt.FormatString("yyyy-mm-dd");
String FileName = dt.FormatString("yyyy-mm-dd hh-nn-ss");
ForceDirectories("C:\\KOSES\\History\\PKGParamLog\\"+ FolderName);
String FullPath = "C:\\KOSES\\History\\PKGParamLog\\"+ FolderName+"\\"+FileName+".txt";
File = new TFileStream(FullPath, fmCreate | fmOpenReadWrite);
File->Position = 0;
String Strtemp = "PKGParamLog \r\n";
for(int i=0; i<PkgParamGrid->RowCount; i++)
{
Strtemp += " No:"+IntToStr(i)+ ":"+ PkgParamGrid->Cells[3][i+1] +"\r\n";
}
File->Write(Strtemp.c_str(),Strtemp.Length());
delete File;
}
示例2: InitCommon
//---------------------------------------------------------------------------
void __fastcall TFormClientRep::InitCommon()
{
SetFormPosStd(this,Screen->Width,750,0,true);
TDateTime DT = Date();
SelYY = MaxYY = CurYY = StrToInt(DT.FormatString("yy"));
SelMM = MaxMM = CurMM = StrToInt(DT.FormatString("m"));
SetDates(CurMM, CurYY);
SetButtonCaption(CurMM);
}
示例3: InitCommon
//---------------------------------------------------------------------------
void __fastcall TFormSummaryRep::InitCommon()
{
SetFormPosStd(this,Screen->Width,750,0,true);
TDateTime DT = Date();
SelYY = MaxYY = CurYY = StrToInt(DT.FormatString("yy"));
SelMM = MaxMM = CurMM = StrToInt(DT.FormatString("m"));
SetDates(CurMM, CurYY);
SetButtonCaption(CurMM);
SetColumns();
ToggleShowCost(false);
}
示例4: AsStr
String TTimeLapse::AsStr(TDateTime dt)
{
if ((int)dt == 0) dt = Elapsed();
dt.DecodeTime(&FHour, &FMin, &FSec, &FMSec);
String str;
if (FHour != 0)
str = dt.FormatString("h':'nn':'ss");
else
str = dt.FormatString("n':'ss");
return str;
}
示例5: setEdits
//---------------------------------------------------------------------------
void TClockDlg::setEdits()
{
initialised = false;
TDateTime corr = dtg::getUTC( correction );
DayEdit->Text = corr.FormatString( "dd" );
MonthEdit->Text = corr.FormatString( "mm" );
YearEdit->Text = corr.FormatString( "yyyy" );
TDateTime dtt = TDateTime( correction );
HoursEdit->Text = dtt.FormatString( "h" );
MinutesEdit->Text = dtt.FormatString( "n" );
SecondsEdit->Text = dtt.FormatString( "s" );
initialised = true;
}
示例6: AsString
String TTimeLapse::AsString(const bool ms, TDateTime dt)
{
if ((int)dt == 0)
dt = Elapsed();
dt.DecodeTime(&FHour, &FMin, &FSec, &FMSec);
String str;
if (FHour != 0)
str = IntToStr(FHour) + " Hours, ";
str += dt.FormatString("n' Minutes, 's");
if (ms)
str += dt.FormatString("'.'z");
str += " Seconds";
return str;
}
示例7: DateTimeToStr
UnicodeString DateTimeToStr(UnicodeString & Result, const UnicodeString & Format,
TDateTime DateTime)
{
(void)Result;
(void)Format;
return DateTime.FormatString(L"");
}
示例8: addChat
void TMinosChatForm::addChat(const std::string &mess)
{
TDateTime dt = TDateTime::CurrentDateTime();
unsigned short h, m, s, ms;
dt.DecodeTime( &h, &m, &s, &ms );
String sdt = dt.FormatString( "hh:nn:ss " ) + mess.c_str();
chatQueue.push_back(sdt.c_str());
}
示例9: AnsiString
AnsiString TUtilities::Format96HHMM(TDateTime DateTime)
//Formats a TDateTime into an AnsiString of the form hh:mm where hh runs from 00 to 95 & resets when it reaches 96
{
AnsiString MinString = DateTime.FormatString(":nn");
int Hours = (int)(((double)(DateTime + 0.0003)) * 24);//for v0.6 round up by ~0.5min to prevent undershooting the hour in formatted tts
while(Hours >= 96) Hours -= 96;
AnsiString HourString = AnsiString(Hours);
while(HourString.Length() < 2) HourString = "0" + HourString;;
return (HourString + MinString);
}
示例10: setDate
// We really need to hold FULL dates internally!
dtg::dtg( bool now )
{
if ( now )
{
TDateTime tdt = dtg::getUTC();
setDate( tdt.FormatString( "dd/mm/yy" ).c_str(), DTGDISP );
setTime( tdt.FormatString( "hh:nn:ss" ).c_str(), DTGDISP );
}
else
{
setDate( "", DTGDISP );
setTime( "", DTGDISP );
}
}
示例11: Loga
void Loga(String msg)
{
FILE *fp;
if ( ( fp = fopen(FILE_LOG, "at")) != NULL )
{
TDateTime dt;
dt = dt.CurrentDateTime();
String S = dt.FormatString("dd/mm/yy hh:nn:ss(");
S = S + GetTickCount() % 1000;
S = S + ") - " + msg;
if ( FormMain->lbLog->Items->Count > 150 )
{
FormMain->lbLog->Items->Delete(0);
}
FormMain->lbLog->Items->Add(S);
fprintf( fp, S.c_str() );
fprintf( fp, "\n" );
fclose( fp );
}
}
示例12: proBar
void CSelfTestMenu::OnButton13(int iEvent, unsigned char * pEventData, int iDataLen)
{
TDateTime curDate;
char chValue[64];
UINT8 nKeyTime = 1;
while(1)
{
curDate = TDateTime::CurrentDateTime();
memset(chValue, 0, sizeof(chValue));
sprintf(chValue, " %s", curDate.FormatString(YYYYMMDDHHMMSS).c_str());
CaProgressBar proBar(chValue);
proBar.Show();
if(CheckKey(nKeyTime)==SUCCESS)
{
break;
}
CommonSleep(1000);
}
this->ReFresh();
return;
}
示例13: GetFDataTag
//---------------------------------------------------------------------------
TData __fastcall MyArhiv::GetFDataTag(TDateTime DateArhiv, int IDTag)
{
struct TData Ret;
static TDateTime Old;
static char NameCurDir[255];
static AnsiString TekDir ;
static bool first=true ;
int handle_file ;
static AnsiString OldName="" ;
static unsigned long kb = 0L;
static bool Error = true;
static double tim;
if (first) // определить текущую директорию
{
GetCurrentDirectory(255,NameCurDir);
TekDir = NameCurDir;
first = false ;
}
if (IDTag>=10000)
{
Ret.Status = 1;
Ret.Val = 0;
Ret.YesData = true;
return Ret;
}
if (Old!=DateArhiv)
{
AnsiString ARHIV = "ARHIV";
AnsiString YEAR = DateArhiv.FormatString("yyyy");
AnsiString MON = DateArhiv.FormatString("mm") ;
AnsiString DAT = DateArhiv.FormatString("dd") ;
AnsiString HOUR = DateArhiv.FormatString("hh") ;
int min = StrToInt(DateArhiv.FormatString("nn"));
int sec = StrToInt(DateArhiv.FormatString("ss"));
Old = DateArhiv;
AnsiString NameFile = TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat";
Error=true;
if ((handle_file=_open(NameFile.c_str(),O_RDONLY|O_BINARY))>0) // чтение информации из файла
{
/* unsigned int kb_zag = sizeof(int)*ActiveArhiv->CountTags+sizeof(int);
unsigned int len_buf = ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double))*3600; // (( значение и статус ) *кол-во тэгов + дата и время) 60 сек * 60 мин
unsigned char *buf; */
if (OldName!=NameFile) // разбор заголовка
{
lseek(handle_file,0L,SEEK_SET) ;
Error = false;
_read(handle_file,&kb,sizeof(int)); // размер заголовка
if (kb == sizeof(int)*ActiveArhiv->CountTags+sizeof(int)) // размер заголовка должен соответствовать количеству архивных тэгов
{
if (_read(handle_file,FArhivIDTags,sizeof(int)*ActiveArhiv->CountTags)!=(signed int)(sizeof(int)*ActiveArhiv->CountTags)) Error=true;
}
else Error = true;
OldName = NameFile;
}
else Error = false;
if (!Error)
{
unsigned long sm = min * 60 + sec;
sm = kb + sm * ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double));
sm = lseek(handle_file,sm,SEEK_SET);
if (_read(handle_file,(unsigned char *)&tim,sizeof(double))!=sizeof(double)) Error=true;
else if (_read(handle_file,(unsigned char *)FArhivValTags,(unsigned int)(sizeof(double)*ActiveArhiv->CountTags))!=(signed int)(sizeof(double)*ActiveArhiv->CountTags)) Error=true;
else if (_read(handle_file,(unsigned char *)FArhivStatTags,sizeof(int)*ActiveArhiv->CountTags)!=(signed int)(sizeof(int)*ActiveArhiv->CountTags)) Error=true;
}
_close(handle_file);
handle_file = -1;
}
}
if ((tim==0)||(Error)) { FDataTag.YesData=false;FDataTag.Val=0;FDataTag.Status=1; }
else
{
FDataTag.YesData=false;
for (int pc=0;pc<FCountTags;pc++)
{
if (FArhivIDTags[pc]==IDTag)
{
FDataTag.Val = FArhivValTags[pc];
FDataTag.Status = FArhivStatTags[pc];
FDataTag.YesData = true;break;
}
}
if (!FDataTag.YesData) { FDataTag.Val=0;FDataTag.Status=1; }
}
Ret = FDataTag;
return Ret;
}
示例14: DateTimeToString
UnicodeString DateTimeToString(TDateTime DateTime)
{
return DateTime.FormatString(L"");
}
示例15: Now
/*int old_sec=-1;
unsigned int old_kb=1000; */
void __stdcall Timer1Timer(UINT TimerID, UINT Message, DWORD dwUser, DWORD dw1, DWORD dw2)
{
// раз в секунду запись в архив
static char NameCurDir[255];
static AnsiString TekDir ;
static bool first=true ;
int handle_file ;
AnsiString ARHIV = "ARHIV";
TDateTime TD = Now();
AnsiString YEAR = TD.FormatString("yyyy");
AnsiString MON = TD.FormatString("mm") ;
AnsiString DAT = TD.FormatString("dd") ;
AnsiString HOUR = TD.FormatString("hh") ;
int min = StrToInt(TD.FormatString("nn"));
int sec = StrToInt(TD.FormatString("ss"));
double tim = TD.Val;
/*if ((old_sec!=-1)&&((sec-old_sec)>1)&&(old_sec!=59))
int l=0;
old_sec = sec;*/
if (ActiveArhiv==NULL) return;
if (first) // определить текущую директорию
{
GetCurrentDirectory(255,NameCurDir);
TekDir = NameCurDir;
first = false ;
}
AnsiString NameFile = TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat";
if (!FileExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat")) // создать файл ARHIV\\XXXX\\MM\\DD\\hh - час
{
// Проверить наличие директории ARHIV
if (!DirectoryExists(TekDir+"\\"+ARHIV)) if (!CreateDir(TekDir+"\\"+ARHIV)) { ActiveArhiv->Com=-10;/* FErrorDostup=true;*/return; }
// Проверить наличие директории ARHIV\\XXXX - год
if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR)) if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR)) { ActiveArhiv->Com=-10; /* FErrorDostup=true; */return; }
// Проверить наличие директории ARHIV\\XXXX\\MM - месяц
if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON)) if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON)) { ActiveArhiv->Com=-10; /*FErrorDostup=true; */return; }
// Проверить наличие директории ARHIV\\XXXX\\MM\\DD - день
if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT)) if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT)) { ActiveArhiv->Com=-10;/*FErrorDostup=true;*/return; }
// создать файл ARHIV\\XXXX\\MM\\DD\\hh - час
if ((handle_file=_open(NameFile.c_str(),O_RDWR|O_BINARY|O_CREAT))>0) // создание нулевого файла
{
unsigned int kb_zag = sizeof(int)*ActiveArhiv->CountTags+sizeof(int);
unsigned char *buf;
lseek(handle_file,0L,SEEK_SET);
_write(handle_file,(unsigned char *)&kb_zag,sizeof(int)) ;
_write(handle_file,(unsigned char *)ActiveArhiv->IDTags,sizeof(int)*ActiveArhiv->CountTags);
unsigned int len_buf = ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double))*3600; // (( значение и статус ) *кол-во тэгов + дата и время) 60 сек * 60 мин
buf = (unsigned char *)calloc(len_buf,sizeof(char));
// заполнение нулями
_write(handle_file,(unsigned char *)buf,len_buf);
_close(handle_file);
handle_file=-1;
free(buf);
}
else { ActiveArhiv->Com = -10;/* FErrorDostup = true; */return; }
}
if ((handle_file=_open(NameFile.c_str(),O_RDWR|O_CREAT|O_BINARY))>0) // Запись информации в файл
{
// чтение размера заголовка
unsigned int kb = 0L;
unsigned long sm = min * 60 + sec;
/* static int old_sm=0;
if ((sm-old_sm)>1)
{
int k=0;
}
old_sm=sm; */
lseek(handle_file,0L,SEEK_SET);
_read(handle_file,&kb,sizeof(int));
/* int k2=0;
else
if ((old_kb!=kb)&&(old_kb!=1000))
int k3=0;
old_kb=kb;*/
sm = kb + sm * ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double));
lseek(handle_file,sm,SEEK_SET);
_write(handle_file,&tim,sizeof(double));//!=sizeof(double))
/* int k4=0; */
/*if (ActiveArhiv->ValTags[1]<1)
int i=0;
if (
*/
_write(handle_file,(unsigned char *)ActiveArhiv->ValTags,sizeof(double)*ActiveArhiv->CountTags);
/*!=sizeof(double)*ActiveArhiv->CountTags)
int k=0;
if (*/
_write(handle_file,(unsigned char *)ActiveArhiv->StatTags,sizeof(int)*ActiveArhiv->CountTags);
/*!=sizeof(int)*ActiveArhiv->CountTags)
int k1=0; */
_close(handle_file);
handle_file=-1;
ActiveArhiv->Com = -11; /* FErrorDostup = false;*/
}
else { ActiveArhiv->Com=-10;/* FErrorDostup = true;*/return; }
}