////////////////////////////////////// // Log-Notify void TLogNotify::OnStatus(const TStr& MsgStr) { TTm NowTm = TTm::GetCurLocTm(); Notify->OnStatus(TStr::Fmt("[%s %s] %s", NowTm.GetYMDDashStr().CStr(), NowTm.GetHMSTColonDotStr(true, false).CStr(), MsgStr.CStr())); }
void TFileNotify::OnStatus(const TStr& MsgStr) { TTm NowTm = TTm::GetCurLocTm(); File->PutStrFmt("[%s %s] %s\n", NowTm.GetYMDDashStr().CStr(), NowTm.GetHMSTColonDotStr(true, false).CStr(), MsgStr.CStr()); File->Flush(); }
/////////////////////////////// // StayPoint detector aggregate void TStayPointDetector::OnAddRec(const TRec& Rec) { // TODO logic State = TJsonVal::NewObj(); State->AddToObj("status", 0); // dump parameters State->AddToObj("parameters", Params); // copy record TTm Timestamp; Rec.GetFieldTm(TimeFieldId, Timestamp); State->AddToObj("lastTimestamp", (double)TTm::GetUnixMSecsFromWinMSecs(Timestamp.GetMSecsFromTm(Timestamp))); State->AddToObj("lastLocationX", Rec.GetFieldFltPr(LocationFieldId).Val1); State->AddToObj("lastLocationY", Rec.GetFieldFltPr(LocationFieldId).Val2); State->AddToObj("lastAccuracy", Rec.GetFieldByte(AccuracyFieldId)); }
void TFileNotify::OnNotify(const TNotifyType& Type, const TStr& MsgStr){ TStr TypeStr = ""; if (Type==ntInfo) TypeStr = "INFO"; else if (Type == ntErr) TypeStr = "ERROR"; else if (Type == ntWarn) TypeStr = "WARNING"; else if (Type == ntStat) TypeStr = "STAT"; TTm NowTm = TTm::GetCurLocTm(); File->PutStrFmt("[%s %s] %s: %s\n", NowTm.GetYMDDashStr().CStr(), NowTm.GetHMSTColonDotStr(true, false).CStr(), TypeStr.CStr(), MsgStr.CStr()); File->Flush(); }
uint64 TSysTm::GetMSecsFromTm(const TTm& Tm){ SYSTEMTIME SysTm; FILETIME FileTm; SysTm.wYear=WORD(Tm.GetYear()); SysTm.wMonth=WORD(Tm.GetMonth()); SysTm.wDayOfWeek=WORD(Tm.GetDayOfWeek()); SysTm.wDay=WORD(Tm.GetDay()); SysTm.wHour=WORD(Tm.GetHour()); SysTm.wMinute=WORD(Tm.GetMin()); SysTm.wSecond=WORD(Tm.GetSec()); SysTm.wMilliseconds=WORD(Tm.GetMSec()); ESAssert(SystemTimeToFileTime(&SysTm, &FileTm)); TUInt64 UInt64(uint(FileTm.dwHighDateTime), uint(FileTm.dwLowDateTime)); return UInt64.Val/uint64(10000); }
TTm TSysTm::GetLocTmFromUniTm(const TTm& Tm){ // get time-zone information TIME_ZONE_INFORMATION TzInf; GetTimeZoneInformation(&TzInf); // get system time SYSTEMTIME UniSysTm; UniSysTm.wYear=WORD(Tm.GetYear()); UniSysTm.wMonth=WORD(Tm.GetMonth()); UniSysTm.wDayOfWeek=WORD(Tm.GetDayOfWeek()); UniSysTm.wDay=WORD(Tm.GetDay()); UniSysTm.wHour=WORD(Tm.GetHour()); UniSysTm.wMinute=WORD(Tm.GetMin()); UniSysTm.wSecond=WORD(Tm.GetSec()); UniSysTm.wMilliseconds=WORD(Tm.GetMSec()); // convert system-time SYSTEMTIME LocSysTm; SystemTimeToTzSpecificLocalTime(&TzInf, &UniSysTm, &LocSysTm); // return local-time return TTm(LocSysTm.wYear, LocSysTm.wMonth, LocSysTm.wDay, LocSysTm.wDayOfWeek, LocSysTm.wHour, LocSysTm.wMinute, LocSysTm.wSecond, LocSysTm.wMilliseconds); }
TTm TSysTm::GetUniTmFromLocTm(const TTm& Tm){ // get time-zone information TIME_ZONE_INFORMATION TzInf; GetTimeZoneInformation(&TzInf); // get system time SYSTEMTIME LocSysTm; LocSysTm.wYear=WORD(Tm.GetYear()); LocSysTm.wMonth=WORD(Tm.GetMonth()); LocSysTm.wDayOfWeek=WORD(Tm.GetDayOfWeek()); LocSysTm.wDay=WORD(Tm.GetDay()); LocSysTm.wHour=WORD(Tm.GetHour()); LocSysTm.wMinute=WORD(Tm.GetMin()); LocSysTm.wSecond=WORD(Tm.GetSec()); LocSysTm.wMilliseconds=WORD(Tm.GetMSec()); // convert system-time SYSTEMTIME UniSysTm=LocSysTm; Fail; // BCB5.0 doesn't find TzSpecificLocalTimeToSystemTime //TzSpecificLocalTimeToSystemTime(&TzInf, &LocSysTm, &UniSysTm); // return system-time return TTm(UniSysTm.wYear, UniSysTm.wMonth, UniSysTm.wDay, UniSysTm.wDayOfWeek, UniSysTm.wHour, UniSysTm.wMinute, UniSysTm.wSecond, UniSysTm.wMilliseconds); }
TStr TBackupProfile::GetFolderNameForCurrentTime() const { TTm Now = TTm::GetCurLocTm(); return Now.GetYMDDashStr() + " " + TStr::Fmt("%02d-%02d-%02d", Now.GetHour(), Now.GetMin(), Now.GetSec()); }
TSecTm::TSecTm(const TTm& Tm): AbsSecs( TSecTm(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), int(TMath::Round(Tm.GetSec()*1000+Tm.GetMSec()))).GetAbsSecs()){}
uint TTm::GetDateTimeIntFromTm(const TTm& Tm) { return GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(), Tm.GetMin()); }
uint TTm::GetYearIntFromTm(const TTm& Tm) { return GetDateTimeInt(Tm.GetYear()); }
TSecTm::TSecTm(const TTm& Tm): AbsSecs( TSecTm(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), Tm.GetSec()).GetAbsSecs()) { }
uint TTm::GetDateTimeIntFromTm(const TTm& Tm) { return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), Tm.GetSec()) : 0; }
uint TTm::GetYearIntFromTm(const TTm& Tm) { return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear()) : 0; }