这篇教程C++ stime函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中stime函数的典型用法代码示例。如果您正苦于以下问题:C++ stime函数的具体用法?C++ stime怎么用?C++ stime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了stime函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: settimestatic void settime(cell hour,cell minute,cell second){ #if defined __WIN32__ || defined _WIN32 || defined WIN32 SYSTEMTIME systim; GetLocalTime(&systim); if (hour!=CELLMIN) systim.wHour=(WORD)wrap((int)hour,0,23); if (minute!=CELLMIN) systim.wMinute=(WORD)wrap((int)minute,0,59); if (second!=CELLMIN) systim.wSecond=(WORD)wrap((int)second,0,59); SetLocalTime(&systim); #else /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you * must have "root" permission to call stime() */ time_t sec1970; struct tm gtm; time(&sec1970); gtm=*localtime(&sec1970); if (hour!=CELLMIN) gtm.tm_hour=wrap((int)hour,0,23); if (minute!=CELLMIN) gtm.tm_min=wrap((int)minute,0,59); if (second!=CELLMIN) gtm.tm_sec=wrap((int)second,0,59); sec1970=mktime(>m); stime(&sec1970); #endif}
开发者ID:Azon099,项目名称:ivmp-modules,代码行数:32,
示例2: open/****************************************************************************** * version: 1.0 * author: link * date: 2015.11.10 * brief: 设置系统时间******************************************************************************/int LINUX_RTC::set_rtc(rtc_time rtc_tm){ int ret; int rtc_fd; time_t t1; rtc_tm.tm_year -= 1900; //年从1900开始 rtc_tm.tm_mon -= 1; //月从0开始 rtc_fd = open("/dev/rtc0", O_RDWR, 0); //打开RTC if (rtc_fd == -1){ printf("/dev/rtc0 open error/n"); return -1; } t1 = timelocal((tm*)&rtc_tm); //设置系统时间 stime(&t1); ret = ioctl(rtc_fd, RTC_SET_TIME, &rtc_tm); //设置RTC时间 if (ret == -1){ printf("rtc ioctl RTC_SET_TIME error/r/n"); return -1; } close(rtc_fd); //关闭RTC return 0;}
开发者ID:link8001,项目名称:aip,代码行数:34,
示例3: settimeintsettime (struct timespec const *ts){#if defined CLOCK_REALTIME && HAVE_CLOCK_SETTIME { int r = clock_settime (CLOCK_REALTIME, ts); if (r == 0 || errno == EPERM) return r; }#endif#if HAVE_SETTIMEOFDAY { struct timeval tv; tv.tv_sec = ts->tv_sec; tv.tv_usec = ts->tv_nsec / 1000; return settimeofday (&tv, 0); }#elif HAVE_STIME /* This fails to compile on OSF1 V5.1, due to stime requiring a `long int*' and tv_sec is `int'. But that system does provide settimeofday. */ return stime (&ts->tv_sec);#else errno = ENOSYS; return -1;#endif}
开发者ID:DavidChenLiang,项目名称:study,代码行数:29,
示例4: n_settimestamp/* settimestamp(seconds1970) sets the date and time from a single parameter: the * number of seconds since 1 January 1970. */static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params){ #if defined __WIN32__ || defined _WIN32 || defined WIN32 int year, month, day, hour, minute, second; stamp2datetime(params[1], &year, &month, &day, &hour, &minute, &second); setdate(year, month, day); settime(hour, minute, second); #else /* Linux/Unix (and some DOS compilers) have stime(); on Linux/Unix, you * must have "root" permission to call stime(); many POSIX systems will * have settimeofday() instead */ #if defined __APPLE__ /* also valid for other POSIX systems */ struct timeval tv; tv.tv_sec = params[1]; tv.tv_usec = 0; settimeofday(&tv, 0); #else time_t sec1970=(time_t)params[1]; stime(&sec1970); #endif #endif (void)amx; return 0;}
开发者ID:ChairGraveyard,项目名称:TES3MP,代码行数:32,
示例5: Dijint Dij(int st,int en){ memset(f,-1,sizeof(f)); memset(tag,0,sizeof(tag)); int i,j,k,ll,p; f[st]=0;h[st]=0; for (ll=0;ll<n;ll++){ p=-1; for (i=1;i<=n;i++) if (f[i]>-1 && !tag[i]) if (p==-1 || f[i]<f[p]) p=i; if (p==-1) break; tag[p]=1; for (j=0;j<gn[p];j++){ k=g[p][j]; int time=stime(p,k,f[p])+d[p][k]; if (time<0) continue; if (f[k]==-1 || time<f[k]){ f[k]=time; h[k]=p; } } } if (f[en]==-1) return 0; printf("%d/n",f[en]); pr(en); printf("/n"); return 1;}
开发者ID:TRYang,项目名称:acm,代码行数:28,
|