在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > C語言獲取編譯日期時間和系統(tǒng)時間

            C語言獲取編譯日期時間和系統(tǒng)時間

            作者: 時間:2016-11-27 來源:網(wǎng)絡(luò) 收藏
            int GetCompileDateTime(char *szDateTime)
            {
            const intMONTH_PER_YEAR=12;
            const char szEnglishMonth[MONTH_PER_YEAR][4]={ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
            char szTmpDate[40]={0};
            char szTmpTime[20]={0};
            char szMonth[4]={0};
            int iYear,iMonth,iDay,iHour,iMin,iSec;//,,

            //獲取編譯日期、時間
            sprintf(szTmpDate,"%s",__DATE__); //"Sep 18 2010"
            sprintf(szTmpTime,"%s",__TIME__);//"10:59:19"

            sscanf(szTmpDate,"%s %d %d",szMonth,&iDay,&iYear);
            sscanf(szTmpTime,"%d:%d:%d",&iHour,&iMin,&iSec);

            for(int i=0;MONTH_PER_YEAR;i++)
            {
            if(strncmp(szMonth,szEnglishMonth[i],3)==0)
            {
            iMonth=i+1;
            break;
            }
            }

            printf("%d,%d,%d,%d,%d,%d",iYear,iMonth,iDay,iHour,iMin,iSec);
            sprintf(szDateTime,"dddddd",iYear,iMonth,iDay,iHour,iMin,iSec);
            return 0;
            }
            typedefstruct
            {
            unsignedintYear;
            unsignedintMonth;
            unsignedintDate;
            unsignedintHours;
            unsignedintMinutes;
            unsignedintSeconds;
            }BuildDateTime;

            constunsignedcharMonthStr[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

            voidGetBuildDateTime(BuildDateTime*p_BuildDateTime)
            {
            unsignedchartemp_str[4]={0,0,0,0},i=0;

            sscanf(__DATE__,"%s - M",temp_str,&(p_BuildDateTime->Date),&(p_BuildDateTime->Year));
            sscanf(__TIME__,"-:-:-",&(p_BuildDateTime->Hours),&(p_BuildDateTime->Minutes),&(p_BuildDateTime->Seconds));
            for(i=0;i<12;i++)
            {
            if(temp_str[0]==MonthStr[i][0]&&temp_str[1]==MonthStr[i][1]&&temp_str[2]==MonthStr[i][2])
            {
            p_BuildDateTime->Month=i+1;
            break;
            }
            }
            }
            使用方法示例:
            BuildDateTimeMyBuildDateTime;

            GetBuildDateTime(&MyBuildDateTime);

            RTC_YEAR=MyBuildDateTime.Year;
            RTC_MONTH=MyBuildDateTime.Month;
            RTC_DATE=MyBuildDateTime.Date;
            RTC_HOURS=MyBuildDateTime.Hours;
            RTC_MINUTES=MyBuildDateTime.Minutes;
            RTC_SECONDS=MyBuildDateTime.Seconds;

            __LINE__ 當(dāng)前語句所在的行號, 以10進(jìn)制整數(shù)標(biāo)注.
            __FILE__ 當(dāng)前源文件的文件名, 以字符串常量標(biāo)注.
            __DATE__ 程序被編譯的日期, 以"Mmm dd yyyy"格式的字符串標(biāo)注.
            __TIME__ 程序被編譯的時間, 以"hh:mm:ss"格式的字符串標(biāo)注, 該時間由asctime返回.

            __STDC__ 如果當(dāng)前編譯器符合ISO標(biāo)準(zhǔn), 那么該宏的值為1
            __STDC_VERSION__ 如果當(dāng)前編譯器符合C89, 那么它被定義為199409L, 如果符合C99, 那么被定義為199901L.

            __STDC_HOSTED__ 如果當(dāng)前系統(tǒng)是"本地系統(tǒng)(hosted)", 那么它被定義為1. 本地系統(tǒng)表示當(dāng)前系統(tǒng)擁有完整的標(biāo)準(zhǔn)C庫.

            本文引用地址:http://www.biyoush.com/article/201611/322574.htm



            評論


            技術(shù)專區(qū)

            關(guān)閉