天天看點

嵌入式,時間程式設計

UTC标準時間

CT月曆時間,從一個标準時間點(如1970.1.1     0點)到現在所經曆的秒數

月曆時間擷取  time_t  time(time_t  *tloc)    

月曆時間轉化為标準時間  strut  tm  *gmtime(time_t  *timep)

月曆時間轉化為本地時間  strut  tm  *localtime(time_t  *timep)

tm 結構體

      struct   tm {

                  int  tm_sec;                秒值

                  int  tm_min;                分值

                  int  tm_hour;              小時       

                  int  tm_mday;            本月第幾日

                  int  tm_mon ;             本年第幾月

                  int  tm_year;              tm_year+1900=今年

                  int  tm_wday;             本周第幾日

                  int  tm_yday;              本年第幾日

                  int  tm_isdst;              日光節約時間

                   }

将tm格式的時間轉化為字元串格式   char *asctime(const  struct  tm  *tm)

将月曆時間轉化為字元竄格式    char  *ctime  (const  time_t  timep)

擷取今日淩晨到現在的時間差  int  gettimeofday(struct timeval  *tv,struct timezone  *tz)

        struct  timeval  {

                   int  tv_sec;     秒數

                   int  tv_usec       微秒

                            }

延時執行 unsigned int sleep (unsigned int sec)      使程式睡眠n秒

                void  usleep(unsigned  long  usec)          使程式睡眠微秒

繼續閱讀