0
A
回答
1
我不知道任何預定義的方法在bios.h
返回當前日期的BIOS。爲了這個目的,你可以使用time.h
像這些..
方式1:
#include <stdio.h>
#include <time.h>
void main()
{
char *Day[7] = {
"Sunday" , "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
char *Month[12] = {
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
};
char *Suffix[] = { "st", "nd", "rd", "th" };
int i = 3;
struct tm *OurT = NULL;
time_t Tval = 0;
Tval = time(NULL);
OurT = localtime(&Tval);
switch(OurT->tm_mday)
{
case 1: case 21: case 31:
i= 0; /* Select "st" */
break;
case 2: case 22:
i = 1; /* Select "nd" */
break;
case 3: case 23:
i = 2; /* Select "rd" */
break;
default:
i = 3; /* Select "th" */
break;
}
printf("\nToday is %s the %d%s %s %d", Day[OurT->tm_wday],
OurT->tm_mday, Suffix[i], Month[OurT->tm_mon], 1900 + OurT->tm_year);
printf("\nThe time is %d : %d : %d",
OurT->tm_hour, OurT->tm_min, OurT->tm_sec);
}
方式2:
#include<stdio.h>
#include<time.h>
int main(void)
{
time_t t;
time(&t);
printf("Todays date and time is : %s",ctime(&t));
return 0;
}
和here是一個很好的關於bios.h和time.h方法的教程。
0
從您在自己的鏈接中發佈的示例無償擴展。
/* Example for biostime */
#include <stdio.h>
#include <bios.h>
void main()
{
long ticks;
ticks = biostime (0, 0L);
printf("Ticks since midnight is %d\n", ticks);
printf("The seconds since midnight is %d\n", ticks*18.2);
int allSeconds = ticks*18.2;
int hours = allSeconds/3600;
int minutes = allSeconds/60 - hours * 60;
int seconds = allSeconds % 60;
// I like military time, if you don't covert it and add an AM/PM indicator.
printf("The bios time is %02d:%02d:%02d\n", hours, minutes, seconds);
}
相關問題
- 1. 閱讀日期和時間異常
- 2. BIOS閱讀板塊
- 3. 如何閱讀時區日期時間對象
- 4. 如何閱讀使用OleDb日期時間列xls文件
- 5. 閱讀使用C#的BIOS#
- 6. 如何從日期時間戳的時間和日期在PHP
- 7. 如何從日期時間戳得到時間和日期
- 8. c#如何確定BIOS日期更改
- 9. 用日期和時間讀取csv
- 10. 如何日期和時間轉換成日期時間/時間戳
- 11. 閱讀時間
- 12. 如何使用readr閱讀無日期的日期?
- 13. PHP Spreadsheet_Excel_Reader - 閱讀日期
- 14. Python來閱讀Javascript日期
- 15. 閱讀日期與作爲分隔符的時間段
- 16. 如何編寫和讀取日期時間字典
- 17. 如何在Perl中讀取系統時間和日期?
- 18. 以日期作爲輸入並閱讀月份和日期
- 19. 如何與時間和日期
- 20. 如何比較日期和時間
- 21. Java如何添加時間和日期
- 22. 如何查詢SQL日期和時間
- 23. 如何篩選日期和時間
- 24. 如何區分日期和時間?
- 25. 如何從日期和時間
- 26. 如何結合日期和時間WPF
- 27. 如何獲得日期和時間zendframework
- 28. 如何顯示日期和時間datebox
- 29. Java的休眠從MySQL日期時間截斷一部分時間在閱讀
- 30. 將日期和時間轉換爲GMT + 10日期和時間
如果目標機器沒有BIOS,該怎麼辦? – 2011-06-10 10:27:02
您提供的鏈接中有很多示例。你有沒有試過看過他們,看看你能否想出來? – 2011-06-10 10:27:50
我試過_bios_timeofday返回當前時間,但對於當前日期我不知道 – Lalchand 2011-06-10 10:29:07