/* -----------------------------------------------------------------------------*/ static void benchMark1(long *elapsed) { unsigned long d1, d2; GetDateTime (&d1); reference(); GetDateTime (&d2); *elapsed = (d2 - d1) * 1000; }
static void benchMark(long *elapsed, BenchProcPtr f) { unsigned long d1, d2; short refNum; refNum = MidiOpen(ApplName); if (f) f(refNum); GetDateTime(&d1); reference(); GetDateTime(&d2); MidiClose(refNum); *elapsed = (d2 - d1) * 1000; }
/* * The geographic location and time zone information of a Mac * are stored in extended parameter RAM. The ReadLocation * produdure uses the geographic location record, MachineLocation, * to read the geographic location and time zone information in * extended parameter RAM. * * Because serial port and SLIP conflict with ReadXPram calls, * we cache the call here. * * Caveat: this caching will give the wrong result if a session * extend across the DST changeover time, but * this function resets itself every 2 hours. */ static void myReadLocation(MachineLocation * loc) { static MachineLocation storedLoc; /* InsideMac, OSUtilities, page 4-20 */ static time_t first_call = 0, last_call = 86400; if ((last_call - first_call) > 7200) { GetDateTime(&first_call); ReadLocation(&storedLoc); } GetDateTime(&last_call); *loc = storedLoc; }
//--------------------------------------------------------------------- void SaveData::save(int num, int scenario_pos) { //---- is_data[num] = true; //---- this->scenario_pos[num] = scenario_pos; //---- char c[256]; DATEDATA date; GetDateTime(&date); std::stringstream ds; sprintf_s(c, "%02d", date.Year); ds << c << "/"; sprintf_s(c, "%02d", date.Mon); ds << c << "/"; sprintf_s(c, "%02d", date.Day); ds << c; save_day[num] = ds.str(); //---- ds.str(""); sprintf_s(c, "%02d", date.Hour); ds << c << ":"; sprintf_s(c, "%02d", date.Min); ds << c; save_time[num] = ds.str(); //---- save(); }
void gpp_get_clock (long *pdt) { long secs; DateTimeRec dateRec; static DateTimeRec baseDateRec = {1980, 1, 1, 0, 0, 0, 1}; long pdtmp[2]; void do_get_clock (DateTimeRec *dateRec, long *pdt); GetDateTime ((unsigned long *) &secs); // SecsondsToDate (secs, &dateRec); do_get_clock (&dateRec , pdt); do_get_clock (&baseDateRec, pdtmp); /* If the date is reasonable, subtract the days since Jan. 1, 1980 */ if (pdtmp[0] < pdt[0]) pdt[0] -= pdtmp[0]; #ifdef DEBUG_CLOCK printf("pdt[0] = %ld pdt[1] = %ld\n", pdt[0], pdt[1]); #endif }
/** * @param strReportName - report file name. */ void CExpressModeDlg::GetReportFileName(CString& strReportName) { strReportName.Empty(); if (! m_pXMLElementDocument) return; CString strTimeStamp; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./timestamp"), strTimeStamp); if (! strTimeStamp.IsEmpty()) { ULONGLONG uiTimeStamp = _tcstoui64(strTimeStamp, NULL, 0); if (uiTimeStamp != 0) { CString strApplication; GetXMLNodeText(m_pXMLElementDocument, OLESTR("./application"), strApplication); if (! strApplication.IsEmpty()) { int nLength = strApplication.GetLength(); for (int i = 0; i < nLength; ++i) { TCHAR chValue = strApplication.GetAt(i); if (_istalnum(chValue)) strReportName += chValue; } strReportName += _T('_'); } SYSTEMTIME DateTime; GetDateTime(uiTimeStamp, DateTime); CString strTimeStamp; strTimeStamp.Format(_T("error_report_%02d%02d%02d-%02d%02d%02d.log"), DateTime.wYear % 100, DateTime.wMonth, DateTime.wDay, DateTime.wHour, DateTime.wMinute, DateTime.wSecond); strReportName += strTimeStamp; } } }
LRESULT CShdrFileEchoView::OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { int delay; KillTimer ( 1); OutputTokens(); std::string info = _backend->UpdatedShdrString(localvalues); if(!info.empty()) EchoShdr(info.c_str()); localvalues=_backend->_values; GetNextTokens(); if(tokens.size() < 1) { // That's it all done for now. Have to start again. return 0; } intime = GetDateTime(tokens[0]); if(lasttime.m_dt == 0.0) lasttime=intime; diff= (intime-lasttime); ::AtlTrace("Diff = %f\n", diff.GetTotalSeconds()); delay = diff.GetTotalSeconds() * 1000; delay = delay * _dOverride ; if(delay<1) delay=100; lasttime=intime; SetTimer(1,delay); return 0; }
int gettimeofday (struct timeval *tv, struct timezone *tz) { TTime tt; TDate td; GetDateTime(&td, &tt); if (NULL != tv) { struct tm t; t.tm_sec = tt.sec; t.tm_min = tt.min; t.tm_hour = tt.hour; t.tm_mday = td.day; t.tm_mon = td.month-1; t.tm_year = td.year-1900; t.tm_wday = GetWeek(&td); t.tm_yday = GetDay(&td); t.tm_isdst = 0; t.tm_gmtoff = 10800; t.tm_zone = "EEST"; tv->tv_sec = mktime(&t); } if (NULL != tz) { tz->tz_dsttime = 0; tz->tz_minuteswest = -180; } return 0; }
void CShdrEchoInstance::Open() { // FIXME: blank lines and other stuff not handled well. if(GetFileAttributesA(_shdrfilename.c_str())== INVALID_FILE_ATTRIBUTES) { _shdrfilename= ::ExeDirectory() + _shdrfilename; } in.open(_shdrfilename.c_str()); if(GetNextTokens()) { lasttime = GetDateTime(tokens[0]); //SetTimer ( 1, 1000 ); OutputTokens(); localvalues=_backend->_values; std::string info=_backend->ShdrString(_backend->_values);; if(!info.empty()) EchoShdr(info.c_str()); } else { Fault(); std::cout << StdStringFormat("Problem reading file%s\n", ShdrFilename().c_str()); } }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ ChangeWindowMode(TRUE); gFPS.SetDefaultFPS(60); if( DxLib_Init() == -1 ){ return -1; // エラーが起きたら直ちに終了 } ChangeFontType(DX_FONTTYPE_ANTIALIASING_EDGE); SetMouseDispFlag(TRUE); gameManager.SetStage(gameManager.Load); for(;;){ //メインループ ClearDrawScreen(); if(ProcessMessage()==-1 || GameMain()==1){break;} //ゲーム本体を実行 //FPS描画 int NowFPS = gFPS.Get(); int Col = (int)(255 * NowFPS / gFPS.GetDefaultFPS()); //DrawFormatString(500,450,GetColor(255,Col,Col),"FPS: %d",NowFPS); ScreenFlip(); if((GetJoypadInputState( DX_INPUT_KEY_PAD1 ) & PAD_INPUT_10) !=0){ GetDateTime( &Date ); std::stringstream fname; fname <<"img" << Date.Year << Date.Mon << Date.Day <<Date.Hour <<Date.Min <<GetNowCount() << ".png"; SaveDrawScreenToPNG( 0 , 0 , 480 , 480 ,fname.str().c_str()) ; } gFPS.Fix(); } DxLib_End() ; // DXライブラリ使用の終了処理 return 0 ; // ソフトの終了 }
P2(PUBLIC pascal trap, OSErr, DIZero, INTEGER, dn, StringPtr, vname) { OSErr err; LONGINT time; int name_len; char *name; our_file_info_t oi; name_len = vname[0]; name = alloca(name_len + 1); memcpy(name, vname+1, name_len); name[name_len] = 0; GetDateTime(&time); err = get_vref_dref (dn, &oi.vref, &oi.dref); if (err == noErr) { oi.pos = 0; err = begin_track_buffering_for_write (); if (err == noErr) { OSErr err2; err = format_disk(time, name, FLOPPY_SECTORS_PER_DISK, writefunc, (int) &oi); err2 = end_track_buffering_for_write (&oi); if (err == noErr) err = err2; } } return err; }
int main ( int argc, char *argv[] ) { FILE *fp; time_t ltime; // // check the number of parameters // if (argc != 3) { PrintUsage (); return -1; } // // open the TIME file, if not exists, return // fp = fopen (argv[2], "r+"); if (fp == NULL) { return 0; } // // get time and date from file // if (GetDateTime (fp, <ime) != 0) { fclose (fp); return -1; } // // close the TIME file // fclose (fp); // // open the PE file // fp = fopen (argv[1], "r+b"); if (fp == NULL) { printf ("Error: Cannot open the PE file!\n"); return -1; } // // set time and date stamp to the PE file // if (SetStamp (fp, ltime) != 0) { fclose (fp); return -1; } printf ("Set Date/Time Stamp to %s", ctime (<ime)); // // close the PE file // fclose (fp); return 0; }
void DateAdjustDlg::OnOK() { if (!ready_) return; DateTime date_time; TimeDuration span; PhotoInfoPtr invalid= nullptr; bool adjust_time_mode= !!IsDlgButtonChecked(IDC_ADJUST); if (adjust_time_mode) { CWaitCursor wait; int d= 0, h= 0, m= 0, s= 0; if (!CheckAdjustment(photos_, invalid, span, d, h, m, s)) { if (invalid) { example_time_ = invalid->GetDateTime(); UpdateExampleAndOkBtn(); oStringstream ost; ost << _T("This time adjustment will not work for image ") << invalid->GetName() << _T("."); new BalloonMsg(GetDlgItem(IDC_ADJUST), _T("Relative Adjustment Out of Range"), ost.str().c_str(), BalloonMsg::IERROR); } // if invalid == null then span itself is bogus return; } else { // store current entries in registry profile_days_ = d; profile_hours_ = h; profile_minutes_ = m; profile_seconds_ = s; days_ = d; hours_ = h; minutes_ = m; seconds_ = s; } } else { if (!GetDateTime(date_time)) return; // store d/t in registry profile_date_time_ = ToISOString(date_time); } // store current entries in registry profile_adj_mode_ = adj_mode_; DialogChild::OnOK(); }
MgDateTime* MgdSqlDataReader::GetDateTime(INT32 index) { Ptr<MgDateTime> ret; MG_FEATURE_SERVICE_TRY() STRING propertyName = GetPropertyName(index); ret = GetDateTime(propertyName); MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdSqlDataReader::GetDateTime") return ret; }
void PrEnd (char *label) { char *GetDateTime (void); sprintf (MsgText, "End %s", GetDateTime()); trlmessage (MsgText); trlmessage (""); sprintf (MsgText,"*** %s complete ***", label); trlmessage (MsgText); }
void PrBegin (char *label) { char *GetDateTime (void); trlmessage ("\n"); sprintf (MsgText,"%s*** %s -- Version %s ***",TRL_PREFIX, label, WF3_CAL_VER); trlmessage (MsgText); sprintf (MsgText,"Begin %s", GetDateTime()); trlmessage (MsgText); }
//$GPRMC,160546.000,A,3958.8450,N,11621.4676,E,0.00,,110412,,*12 //$GPRMC,000250.599,V,3958.8450,N,11621.4676,E,0.00,0.00,060180,,,N*7C void BBKGPS::GPRMCSplit() { //----------------------------------------------------------------- GetDateTime( dotIndexs[8] + 1, dotIndexs[0] + 1 ); KK = GetGpsLock( dotIndexs[1] + 1 ); WW = GetLongLat( dotIndexs[2] + 1 ); JJ = GetLongLon( dotIndexs[4] + 1 ); VV = GetSpedKMH( dotIndexs[6] + 1 ); FF = GetOrientD( dotIndexs[7] + 1 ); //----------------------------------------------------------------- }
static void benchMark11(long *elapsed) { unsigned long d1, d2, d3, t1, t2; short refNum; refNum = MidiOpen(ApplName); GetDateTime(&d1); d1++; do { GetDateTime(&d2); } while (d2 < d1); /* synch with a new second */ t1 = MidiGetTime(); d2 += 180; do { GetDateTime(&d3); } while (d3 < d2); /* wait 3 minutes*/ t2 = MidiGetTime(); MidiClose(refNum); *elapsed = t2 - t1; }
//$GPRMC,160546.000,A,3958.8450,N,11621.4676,E,0.00,,110412,,*12 //$GPRMC,000250.599,V,3958.8450,N,11621.4676,E,0.00,0.00,060180,,,N*7C void BBKGPS::converNMEA() { //----------------------------------------------------------------- MarkDotGPRMC(); //----------------------------------------------------------------- GetDateTime( dotIndexs[8] + 1, dotIndexs[0] + 1 ); KK = GetGpsLock( dotIndexs[1] + 1 ); WW = GetLongLat( dotIndexs[2] + 1 ); JJ = GetLongLon( dotIndexs[4] + 1 ); VV = GetSpedKMH( dotIndexs[6] + 1 ); FF = GetOrientD( dotIndexs[7] + 1 ); //----------------------------------------------------------------- }
void gpp_get_realtime (long *pdt) { UnsignedWide microTickCount, nMicroTickCount; long idate; static const int mstart[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; long secs; DateTimeRec dateRec; static DateTimeRec baseDateRec = {1980, 1, 1, 0, 0, 0, 1}; void do_get_clock (DateTimeRec *dateRec, long *pdt); if ((beginMicroTickCount.lo == 0)&&(beginMicroTickCount.hi == 0) ) { Microseconds(&beginMicroTickCount); } Microseconds(µTickCount); nMicroTickCount.lo = microTickCount.lo - beginMicroTickCount.lo; nMicroTickCount.hi = microTickCount.hi - beginMicroTickCount.hi; GetDateTime ((unsigned long *) &secs); SecondsToDate (secs, &dateRec); /* If the date is reasonable, subtract the days since Jan. 1, 1980 */ idate = ((long) dateRec.year - 1980) * 365 + /* days per year */ (((long) dateRec.year - 1)/4 - 1979/4) + /* intervening leap days */ (1979/100 - ((long) dateRec.year - 1)/100) + (((long) dateRec.month - 1)/400 - 1979/400) + mstart[dateRec.month - 1] + /* month is 1-origin */ dateRec.day - 1; /* day of month is 1-origin */ idate += (2 < dateRec.month && (dateRec.year % 4 == 0 && (dateRec.year % 100 != 0 || dateRec.year % 400 == 0))); pdt[0] = ((idate*24 + dateRec.hour) * 60 + dateRec.minute) * 60 + dateRec.second; pdt[1] = nMicroTickCount.lo * 100; //#define DEBUG_CLOCK 1 #ifdef DEBUG_CLOCK fprintf(stderr,"pdt[0] = %ld pdt[1] = %ld\n", pdt[0], pdt[1]); fprintf(stderr,"b hi[0] = %ld lo[1] = %ld\n", beginMicroTickCount.hi, beginMicroTickCount.lo); fprintf(stderr,"m hi[0] = %ld lo[1] = %ld\n", microTickCount.hi, microTickCount.lo); #endif }
/** * @param uiTimeStamp - time-stamp value. * @param strTimeStamp - date-time string. */ void CExpressModeDlg::GetDateTimeString(ULONGLONG uiTimeStamp, CString& strTimeStamp) { SYSTEMTIME DateTime; GetDateTime(uiTimeStamp, DateTime); const DWORD dwDateTimeSize = 64; PTSTR pszDateTime = strTimeStamp.GetBuffer(dwDateTimeSize); // Computers use different locales, so it's desirable to use universal date and time format. const LCID lcidEnglishUS = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); DWORD dwOutputSize = GetDateFormat(lcidEnglishUS, LOCALE_USE_CP_ACP | DATE_LONGDATE | LOCALE_NOUSEROVERRIDE, &DateTime, NULL, pszDateTime, dwDateTimeSize); if (dwOutputSize < dwDateTimeSize) pszDateTime[dwOutputSize - 1] = _T(' '); GetTimeFormat(lcidEnglishUS, LOCALE_USE_CP_ACP | LOCALE_NOUSEROVERRIDE, &DateTime, NULL, pszDateTime + dwOutputSize, dwDateTimeSize - dwOutputSize); strTimeStamp.ReleaseBuffer(); }
time_t my_time(time_t *time) { time_t tmp_time; GetDateTime(&tmp_time); MACOS_TO_UNIX(tmp_time); if (time) { *time = tmp_time; } return tmp_time; }
static void MacintoshInitializeTime(void) { uint64 upTime; unsigned long currentLocalTimeSeconds, startupTimeSeconds; uint64 startupTimeMicroSeconds; uint32 upTimeSeconds; uint64 oneMillion, upTimeSecondsLong, microSecondsToSeconds; DateTimeRec firstSecondOfUnixTime; /* * Figure out in local time what time the machine started up. This information can be added to * upTime to figure out the current local time as well as GMT. */ Microseconds((UnsignedWide*)&upTime); GetDateTime(¤tLocalTimeSeconds); JSLL_I2L(microSecondsToSeconds, PRMJ_USEC_PER_SEC); JSLL_DIV(upTimeSecondsLong, upTime, microSecondsToSeconds); JSLL_L2I(upTimeSeconds, upTimeSecondsLong); startupTimeSeconds = currentLocalTimeSeconds - upTimeSeconds; /* Make sure that we normalize the macintosh base seconds to the unix base of January 1, 1970. */ firstSecondOfUnixTime.year = 1970; firstSecondOfUnixTime.month = 1; firstSecondOfUnixTime.day = 1; firstSecondOfUnixTime.hour = 0; firstSecondOfUnixTime.minute = 0; firstSecondOfUnixTime.second = 0; firstSecondOfUnixTime.dayOfWeek = 0; DateToSeconds(&firstSecondOfUnixTime, &gJanuaryFirst1970Seconds); startupTimeSeconds -= gJanuaryFirst1970Seconds; /* Now convert the startup time into a wide so that we can figure out GMT and DST. */ JSLL_I2L(startupTimeMicroSeconds, startupTimeSeconds); JSLL_I2L(oneMillion, PRMJ_USEC_PER_SEC); JSLL_MUL(dstLocalBaseMicroseconds, oneMillion, startupTimeMicroSeconds); }
/* This routine simulates stdclib time(), time in seconds since 1.1.1970 The time is in GMT */ static time_t GetTimeMac(void) { unsigned long maclocal; /* * Get the current time expressed as the number of seconds * elapsed since the Mac epoch, midnight, Jan. 1, 1904 (local time). * On a Mac, current time accuracy is up to a second. */ GetDateTime(&maclocal); /* Get Mac local time */ maclocal -= GMTDelta(); /* Get Mac GMT */ MACOS_TO_UNIX(maclocal); return maclocal; /* return unix GMT */ }
uint8_t SetModbusHeader (uint8_t device_id, uint8_t *data_ptr) { /* Get and set timestamp of reading */ OSDateTime timestamp; GetDateTime(×tamp); data_ptr[0] = device_id; data_ptr[1] = sensors_read_all(); data_ptr[2] = (uint8_t)(timestamp.date.RTC_Year); data_ptr[3] = timestamp.date.RTC_Month; data_ptr[4] = timestamp.date.RTC_Day; data_ptr[5] = timestamp.time.RTC_Hour; data_ptr[6] = timestamp.time.RTC_Minute; data_ptr[7] = timestamp.time.RTC_Second; return TRUE; }
void DateAdjustDlg::UpdateExampleAndOkBtn() { if (!ready_) return; if (adj_mode_ == 0) // relative valid_ = GetAdjustedTimeSpan(time_span_); else valid_ = GetDateTime(time_set_); //TODO: check limits? // str = ::DateTimeFmt(dt).c_str(); results_.Invalidate(false); ok_btn_.EnableWindow(valid_); }
void CShdrFileEchoView::Start() { if(GetNextTokens()) { lasttime = GetDateTime(tokens[0]); SetTimer ( 1, 1000 ); OutputTokens(); localvalues=_backend->_values; std::string info=_backend->ShdrString(_backend->_values);; if(!info.empty()) EchoShdr(info.c_str()); } else { MessageBox("Problem reading file\n"); } }
boolean filetouchallparentfolders (ptrfilespec pfs) { tyfilespec fs = *pfs, fsparent; long now; GetDateTime ((unsigned long *) &now); while (true) { if (!filegetparentfolderspec (&fs, &fsparent)) return (true); if (!setmodified (&fsparent, now)) return (false); fs = fsparent; } /*while*/ } /*filetouchallparentfolders*/
boolean filesetmodified (ptrfilespec pfs, long modified) { /* set the modification date of the file. if it's 0, we use the current time. also set the modification date of its parent folder. */ if (modified == 0) GetDateTime ((unsigned long *) &modified); if (!setmodified (pfs, modified)) return (false); filetouchparentfolder (pfs); return (true); } /*filesetmodified*/
int CShdrEchoInstance::GetNextTokens() { bool bSetLastTime=false; tokens.clear(); getline(in,_buffer); if(in.eof( )) { in.clear(); // forget we hit the end of file in.seekg(0, std::ios::beg); // move to the start of the file if(!_bRepeat) return 0; getline(in,_buffer); bSetLastTime=true; } tokens=TrimmedTokenize(_buffer, "|"); if(bSetLastTime && tokens.size()>0) lasttime = GetDateTime(tokens[0]); return tokens.size(); }