30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

int tm_sec; /*seconds after the minute ( 0 to 61 ) */<br />

/* allows for up to two leap seconds */<br />

int tm_min; /* minutes after the hour ( 0 to 59 ) */<br />

int tm_hour; /* hours since midnight ( 0 to 23 ) */<br />

int tm_mday; /* day of month ( 1 to 31 ) */<br />

int tm_mon; /* month ( 0 to 11 where January = 0 ) */<br />

int tm_year; /* years since 1900 */<br />

int tm_wday; /* day of week ( 0 to 6 where Sunday = 0 ) */<br />

int tm_yday; /* day of year ( 0 to 365 where January 1 = 0 ) */<br />

int tm_isdst; /* Daylight Savings Time flag */<br />

}<br />

Remarks: If tm_isdst isa positive value, Daylight Savings is in effect. If it is<br />

zero, Daylight Saving time is not in effect. If it is a negative value, the<br />

status of Daylight Saving Time is not known.<br />

time_t<br />

Description: Represents calendar time values.<br />

Include: <br />

Prototype: typedef long time_t<br />

CLOCKS_PER_SEC<br />

Description: Number of processor clocks per second.<br />

Include: <br />

Prototype: #define CLOCKS_PER_SEC<br />

Value: 1<br />

Remarks: MPLAB C30 returns clock ticks (instruction cycles) not actual time.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

printf ("stop =% ld \ n", dừng lại);<br />

trôi qua = difftime (dừng lại, bắt đầu);<br />

printf ("Thời gian đã qua =% .0f \ n", trôi qua);<br />

}<br />

Đầu ra:<br />

bắt đầu = 0<br />

ngăn chặn = 317<br />

Thời gian đã qua = 317<br />

gmtime<br />

Mô tả: Chuyển đổi lịch thời gian để cấu trúc thời gian thể hiện như Universal<br />

Time<br />

Phối hợp (UTC) còn được gọi asGreenwich Mean Time (GMT).<br />

Bao gồm:<br />

Nguyên mẫu: struct tm * gmtime (time_t * const tod);<br />

Đối số: con trỏ tod gian lưu trữ<br />

Quay trở lại giá trị: Trả về địa chỉ của cấu trúc thời gian.<br />

Ghi chú: Chức năng này phá vỡ todvalue vào cấu trúc thời gian của loại<br />

tm. Theo mặc định, MPLAB C30 trả về thời gian là chu kỳ hướng dẫn. Với<br />

gmtimeand mặc định này localtimewill tương đương trừ gmtime<br />

sẽ returntm_isdst (Daylight Savings Time cờ) là không để cho biết<br />

mà Daylight Savings Time không có hiệu lực.<br />

Thư viện chuẩn C với hàm toán học<br />

2004 Microchip Technology Inc DS51456B trang 321<br />

Ví dụ: # include / * Cho gmtime, asctime, * /<br />

/ * Time_t, tm * /<br />

# include / * Cho printf * /<br />

int main (void)<br />

{<br />

DS51456B-page 318<br />

NULL<br />

2004 Microchip Technology Inc.<br />

giờ time_t;<br />

struct tm * Newtime;<br />

Description: The value of a null pointer constant.<br />

Include: <br />

asctime<br />

Description: Converts the time structure to a character string.<br />

Include: <br />

Prototype: char *asctime(const struct tm *tptr);<br />

Argument: tptr time/date structure<br />

Return Value: Returns a pointer to a character string of the following format:<br />

DDD MMM dd hh:mm:ss YYYY<br />

DDDis day of the week<br />

timer = 1066668182; / * Thứ 16:43:02 ngày 20 tháng 10 năm 2003 * /<br />

Newtime = gmtime (và thời gian);<br />

printf ("UTC thời gian =% s \ n", asctime (Newtime));<br />

}<br />

Đầu ra:<br />

UTC thời gian = Thứ hai ngày 20 tháng 10 năm 2003 16:43:02<br />

localtime<br />

Mô tả: Chuyển đổi một giá trị thời gian địa phương.<br />

Bao gồm:<br />

Nguyên mẫu: struct tm * localtime (const time_t * tod);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!