/* Напечатать время от старта и от последнего вызова с заголовком MESSAGE. Возвращает время от предыдущего вызова и общее время. */ long int PrintTimeT (const char *message, long int * pTotalTime) { long t; TIMER summ, stage; long res; t = get_time (); if (TimerStarted) { ConvertTime (t - StartTime, &summ); ConvertTime (res = t - PrevTime, &stage); printf("Time: total=%2.2d:%2.2d:%2.2d.%2.2d, %s=%2.2d:%2.2d:%2.2d.%2.2d\n", summ.hour, summ.min, summ.sec, summ.tic, message, stage.hour, stage.min, stage.sec, stage.tic); PrevTime = t; *pTotalTime = t - StartTime; } else { TimerStarted = 1; StartTime = PrevTime = t; res = 0; } return res; }
bool FDateTimeStructCustomization::ParseDateTimeZone(const FString& DateTimeZoneString, FDateTime& OutDateTime) { static FString Delimiter = FString(TEXT(" ")); // Split our DatetimeZone string into a date and a timezone marker FString DateString; FString TimezoneString; if (!DateTimeZoneString.Split(Delimiter, &DateString, &TimezoneString, ESearchCase::CaseSensitive, ESearchDir::FromEnd)) { DateString = DateTimeZoneString; } // Trim surrounding whitespace DateString = DateString.TrimTrailing().Trim(); TimezoneString = TimezoneString.TrimTrailing().Trim(); // Validate date FDateTime LocalizedDate; if (DateString.IsEmpty() || !FDateTime::Parse(DateString, LocalizedDate)) { return false; } // Validate timezone marker if (TimezoneString.IsEmpty()) { // If no timezone is present, we assume the user's preferred timezone OutDateTime = ConvertTime(LocalizedDate, GetLocalTimezone(), TIMEZONE_UTC); return true; } // Fail if timezone string isn't numeric if (!TimezoneString.IsNumeric()) { return false; } // Convert timezone into int int32 Timezone = FCString::Atoi(*TimezoneString); Timezone = ConvertShortTimezone(Timezone); // Check for timezones in the full-format HHMM, ex: -0500, +1345, etc const int32 TimezoneHour = Timezone / 100; const bool bHasValidMinuteOffset = ((FMath::Abs(Timezone) % 100) % 15 == 0); const bool bIsTimezoneHourValid = (TimezoneHour >= -12 && TimezoneHour <= 14); if (bHasValidMinuteOffset && bIsTimezoneHourValid) { OutDateTime = ConvertTime(LocalizedDate, Timezone, TIMEZONE_UTC); return true; } // Not a valid time return false; }
wxString CSPDReaderView::GetTimeString(wxUint64 ticks) const { if(!m_bDispAsPerc) { if(m_bUseMilliseconds) { return wxString::Format(wxT("%.5f s"),ConvertTime(ticks)); } return wxString::Format(wxT("%.5f ms"),ConvertTime(ticks)); } return wxString::Format(wxT("%.2f%%"),100.0*(double)ticks/(double)m_pDocument->m_PerfInfo.totalfilteredtime); }
void CFileListView::ShowFileInfo( FileInfo& Item ) { UInt32 nIndex = 0; DeleteAllItems(); if(m_FileStack.size() > 1) { InsertItem(nIndex, "..",1); SetSubItem(nIndex, 1, DIR_STR); SetSubItem(nIndex, 2, DIR_STR); ++nIndex; } for (UInt32 i = 0; i < Item.Chlids.size(); ++i,++nIndex) { FileInfo& info = Item.Chlids[i]; InsertItem(nIndex, info.szName, info.nFileSize ? 0 : 1); if(info.nFileSize > 0) { SetSubItem(nIndex, 1, (char*)ConvertSize(info.nFileSize)); SetSubItem(nIndex, 2, (char*)ConvertSize(info.nCompSize)); SetSubItem(nIndex, 4, info.bDataComplete ? "Y" : "N"); } else { SetSubItem(nIndex, 1, DIR_STR); SetSubItem(nIndex, 2, DIR_STR); } if(info.FileTime != 0) SetSubItem(nIndex, 3, (char*)ConvertTime(&(info.FileTime))); } }
int main() { int input; PrintGreeting(); /*Unless 4 is selected, restart program Does this work?*/ do { DisplayMainMenu(); input = GetValidInt(1, 4); /*Main Menu Options select*/ switch (input) { case 1: ConvertTime(); break; case 2: ConvertCurrency(); break; case 3: ConvertTemp(); break; default: break; } }while(input !=4); return 0; }
FString FDateTimeStructCustomization::ToDateTimeZoneString(const FDateTime& UTCDate) { const int32 DisplayTimezone = GetLocalTimezone(); const FDateTime LocalTime = ConvertTime(UTCDate, TIMEZONE_UTC, DisplayTimezone); return FString::Printf(TEXT("%s %s%0.4d"), *LocalTime.ToString(), (DisplayTimezone >= 0 ? TEXT("+") : TEXT("")), DisplayTimezone); }
int CWndMFC::GetTimeLimit() { TCHAR str[256]; GetDlgItemText(IDC_SECONDS, str, 256); return ConvertTime(str); }
void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) { if (!Input->IsLoaded() || !Output->IsLoaded()) return; for (auto& curDialogue : subs->Events) { line = &curDialogue; newK = 0; oldK = 0; newStart = trunc_cs(ConvertTime(curDialogue.Start)); newEnd = trunc_cs(ConvertTime(curDialogue.End) + 9); // Process stuff auto blocks = line->ParseTags(); for (auto block : blocks | agi::of_type<AssDialogueBlockOverride>()) block->ProcessParameters(TransformTimeTags, this); curDialogue.Start = newStart; curDialogue.End = newEnd; curDialogue.UpdateText(blocks); } }
/* Напечатать время от старта и от последнего вызова с заголовком MESSAGE */ void print_full_time (const char *message) { long t; TIMER summ, stage; #ifdef MEASURE_FULL_TIME TIMER summ_full, stage_full; long t_full = get_full_time (); #endif /* MEASURE_FULL_TIME */ t = get_time (); if (TimerStarted) { ConvertTime (t - StartTime, &summ); ConvertTime (t - PrevTime, &stage); #ifdef MEASURE_FULL_TIME ConvertTime (t_full - StartFullTime, &summ_full); ConvertTime (t_full - PrevFullTime, &stage_full); #endif /* MEASURE_FULL_TIME */ #ifdef MEASURE_FULL_TIME printf("Time: total=%2.2d:%2.2d:%2.2d.%2.2d (%2.2d:%2.2d:%2.2d.%2.2d), %s=%2.2d:%2.2d:%2.2d.%2.2d (%2.2d:%2.2d:%2.2d.%2.2d)\n", summ.hour, summ.min, summ.sec, summ.tic, summ_full.hour, summ_full.min, summ_full.sec, summ_full.tic, message, stage.hour, stage.min, stage.sec, stage.tic, stage_full.hour, stage_full.min, stage_full.sec, stage_full.tic); PrevFullTime = t_full; #else printf("Time: total=%2.2d:%2.2d:%2.2d.%2.2d, %s=%2.2d:%2.2d:%2.2d.%2.2d\n", summ.hour, summ.min, summ.sec, summ.tic, message, stage.hour, stage.min, stage.sec, stage.tic); #endif /* MEASURE_FULL_TIME */ PrevTime = t; } else { TimerStarted = 1; StartTime = PrevTime = t; #ifdef MEASURE_FULL_TIME StartFullTime = PrevFullTime = t_full; #endif /* MEASURE_FULL_TIME */ } }
static void SetFileData(const AString& path, const WIN32_FIND_DATA& finddata, FILE_INFO *file) { file->FileName = path.CatPath(finddata.cFileName); file->ShortName = file->FileName.FilePart(); file->FileSize = (uint64_t)finddata.nFileSizeLow + ((uint64_t)finddata.nFileSizeHigh << 32); file->CreateTime = ConvertTime(finddata.ftCreationTime); file->AccessTime = ConvertTime(finddata.ftLastAccessTime); file->WriteTime = ConvertTime(finddata.ftLastWriteTime); file->Attrib = FILE_FLAG_NORMAL; if (finddata.dwFileAttributes & FILE_ATTRIBUTE_READONLY) file->Attrib &= ~FILE_FLAG_WRITABLE; file->Attrib |= (file->Attrib << 3); file->Attrib |= (file->Attrib << 3); if (finddata.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) file->Attrib |= FILE_FLAG_HIDDEN; if (finddata.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) file->Attrib |= FILE_FLAG_SYSTEM; if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) file->Attrib |= FILE_FLAG_IS_DIR; }
SYSAPI uint64_t _Chela_Date_Now() { // Get the time of the day. timeval tv; struct timezone tz; gettimeofday(&tv, &tz); // Convert the time and return. uint64_t ret = ConvertTime(tv); ret += uint64_t(tz.tz_minuteswest)*TicksPerSecond*UINT64_C(60); return ret; }
void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) { if (!Input->IsLoaded() || !Output->IsLoaded()) return; for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) { AssDialogue *curDialogue = dynamic_cast<AssDialogue*>(*cur); if (curDialogue) { line = curDialogue; newK = 0; oldK = 0; newStart = trunc_cs(ConvertTime(curDialogue->Start)); newEnd = trunc_cs(ConvertTime(curDialogue->End) + 9); // Process stuff curDialogue->ParseASSTags(); curDialogue->ProcessParameters(TransformTimeTags, this); curDialogue->Start = newStart; curDialogue->End = newEnd; curDialogue->UpdateText(); curDialogue->ClearBlocks(); } } }
/* Напечатать время от старта и от последнего вызова с заголовком MESSAGE */ void print_time (const char *message) { long t; TIMER summ, stage; t = get_time (); if (TimerStarted) { ConvertTime (t - StartTime, &summ); ConvertTime (t - PrevTime, &stage); printf("Time: total=%2.2d:%2.2d:%2.2d.%2.2d, %s=%2.2d:%2.2d:%2.2d.%2.2d\n", summ.hour, summ.min, summ.sec, summ.tic, message, stage.hour, stage.min, stage.sec, stage.tic); PrevTime = t; } else { TimerStarted = 1; StartTime = PrevTime = t; } }
/* Вывести в строку время текущее время работы */ void sprint_time (char *buffer) { long t; TIMER summ; t = get_time (); if (TimerStarted) { ConvertTime (t - StartTime, &summ); sprintf (buffer, "%2.2d:%2.2d:%2.2d.%2.2d", summ.hour, summ.min, summ.sec, summ.tic); } else { TimerStarted = 1; StartTime = PrevTime = t; } }
IZ_TIME CTimer::Sub(IZ_TIME time1, IZ_FLOAT time2) { IZ_TIME time = ConvertTime(time2); return Sub(time1, time); }
SYSAPI uint64_t _Chela_Date_UtcNow() { timeval tv; gettimeofday(&tv, NULL); return ConvertTime(tv); }
int coreInput(FILE *stream) { int isPrint = 0;//whether command is print int i; int type = -1; char t[20]; char *require[13]; char temp[256]; wrong = 0; for (i = 0; i < 15; i++) { para[i] = 0; } for (i = 0; i < 15; i++) { require[i] = ""; } fscanf(stream, "%s", t); switch (t[3]) { case 'M'://addMeeting type = 1; break; case 'P': if (t[0] == 'a') {//addPresentation type = 2; } else {//endProgram int temp2; for (temp2 = 0; temp2 < 12; temp2++) { Send(temp2, "E00"); } return 0; } break; case 'C'://addConference type = 3; break; case 'D'://addDevice type = 0; break; case 'B'://addBatch break; case 'n'://PrintSchd isPrint = 1; type = -2; break; } i = 0; fgets(temp, 256 - 1, stream); int length = strlen(temp); if (temp[strlen(temp) - 1] != '\n') { temp[strlen(temp)] = '\0'; } else temp[length - 1] = '\0'; require[i++] = strtok(temp, " ;-�C"); while (require[i++] = strtok(NULL, " ;\n\0")); if (type == -1) {//addBatch int stop = 0; FILE *f = fopen(require[0], "r"); if (f != NULL) { while (!stop) { for (i = 0; i < 256; i++) { temp[i] = '\0'; } fgets(temp, 256 - 1, f); if (temp[strlen(temp) - 1] != '\n') { temp[strlen(temp)] = '\0'; } else temp[strlen(temp) - 1] = '\0'; if (strlen(temp) == 0) { stop = 1; } else { FILE *f2 = fopen("inputModuleTemp.bat", "w"); fseek(f2, 0, SEEK_SET); fwrite(temp, strlen(temp), 1, f2); fclose(f2); FILE *f3 = fopen("inputModuleTemp.bat", "r"); coreInput(f3); } } } else printf("You might entered an empty line of command.\n"); } else if (!isPrint) {//add: equipment, date, time, duration, tenant, equipment, equipment ConvertTime(require[1], require[2]); if (wrong)goto wrongEnd; ConvertDuration(require[3]); if (wrong)goto wrongEnd; ConvertTenant(require[4]); ConvertEquipment(require[0]); int ttemp; for (ttemp = 5; ttemp < 13; ttemp++) { if (require[ttemp] && strcmp(require[ttemp], "") != 0) ConvertEquipment(require[ttemp]); } AddRecord(para[0], para[1], para[2], para[3], para[4], para[5], para[6], para[7], para[8], para[9], para[10], para[11], para[12], para[13], para[14], type); } else {//print if (strcmp(require[0], "fcfs") == 0) { SchdFcfs(head); PrintSchd(head, 1); } else if (strcmp(require[0], "prio") == 0) { SchdPrio(); PrintSchd(head, 2); } else if (strcmp(require[0], "opti") == 0) { SchdOpti(); } else { errorInput(); goto wrongEnd; } } if (isPrint) return 2; else return 1; wrongEnd: { return 1; } }
double ConvertTimeStringOld(char *ts) { int day; int mon; int date; int hour; int min; int sec; int year; int err; struct tm t; time_t utc; double ret; char *curr; curr = ts; /* * [Thu Dec 25 21:06:11 2008] * 2013-02-06 21:04:15 */ while(!isalpha(*curr)) { curr++; if(*curr == 0) { break; } } if(*curr == 0) { return(-1.0); } day = ConvertDay(curr); if(day < 0) { day = 0; /* return(-1.0); */ } while(isalpha(*curr)) { curr++; if(*curr == 0) { return(-1.0); } } while(*curr == ' ') { curr++; if(*curr == 0) { return(-1.0); } } mon = ConvertMonth(curr); if(mon < 0) { return(-1.0); } while(*curr != ' ') { curr++; if(*curr == 0) { return(-1.0); } } while(*curr == ' ') { curr++; if(*curr == 0) { return(-1.0); } } date = atoi(curr); while(*curr != ' ') { curr++; if(*curr == 0) { return(-1.0); } } while(*curr == ' ') { curr++; if(*curr == 0) { return(-1.0); } } err = ConvertTime(curr,&hour,&min,&sec); if(err < 0) { return(-1.0); } while(*curr == ' ') { curr++; if(*curr == 0) { return(-1.0); } } while(*curr != ' ') { curr++; if(*curr == 0) { return(-1.0); } } while(*curr == ' ') { curr++; if(*curr == 0) { return(-1.0); } } year = atoi(curr); memset(&t,0,sizeof(t)); t.tm_sec = sec; t.tm_min = min; t.tm_hour = hour; t.tm_mday = date; t.tm_mon = mon; t.tm_year = year - 1900; t.tm_wday = day; utc = mktime(&t); ret = (double)utc; return(ret); }
double ConvertTimeStringNew(char *ts) { int day; int mon; int date; int hour; int min; int sec; int year; int err; struct tm t; struct tm *now; time_t utc; double ret; char *curr; time_t tval; /* for daylight savings time */ int dst; if(DST == 1) { tval = time(NULL); now = localtime(&tval); if(now != NULL) { dst = now->tm_isdst; } else { dst = 0; } } else { dst = 0; } curr = ts; /* * 2013-02-06 21:04:15 */ while(iswspace(*curr)) { curr++; if(*curr == 0) { break; } } year = atoi(curr); while(isdigit(*curr)) { curr++; if(*curr == 0) { return(-1.0); } } if(*curr != '-') { return(-1.0); } while(*curr == '-') { curr++; if(*curr == 0) { return(-1.0); } } mon = atoi(curr) - 1; while(isdigit(*curr)) { curr++; if(*curr == 0) { return(-1.0); } } if(*curr != '-') { return(-1.0); } while(*curr == '-') { curr++; if(*curr == 0) { return(-1.0); } } date = atoi(curr); while(isdigit(*curr)) { curr++; if(*curr == 0) { return(-1.0); } } if(*curr != ' ') { return(-1.0); } while(iswspace(*curr)) { curr++; if(*curr == 0) { return(-1.0); } } err = ConvertTime(curr,&hour,&min,&sec); if(err < 0) { return(-1.0); } memset(&t,0,sizeof(t)); t.tm_sec = sec; t.tm_min = min; t.tm_hour = hour; t.tm_mday = date; t.tm_mon = mon; t.tm_year = year - 1900; t.tm_wday = day; t.tm_isdst = dst; utc = mktime(&t); ret = (double)utc; return(ret); }
IZ_TIME CTimer::Add(IZ_TIME time1, IZ_FLOAT time2) { IZ_TIME time = ConvertTime(time2); return Add(time1, time); }