30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

tm. By default, MPLAB C30 returns the time as instruction cycles. With<br />

this default gmtimeand localtimewill be equivalent except gmtime<br />

will returntm_isdst(Daylight Savings Time flag) as zero to indicate<br />

that Daylight Savings Time is not in effect.<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 321<br />

Example: #include /* for gmtime, asctime, */<br />

/* time_t, tm */<br />

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

int main(void)<br />

{<br />

time_t timer;<br />

struct tm *newtime;<br />

timer = 1066668182; /* Mon Oct 20 16:43:02 2003 */<br />

newtime = gmtime(&timer);<br />

printf("UTC time = %s\n", asctime(newtime));<br />

}<br />

Output:<br />

UTC time = Mon Oct 20 16:43:02 2003<br />

localtime<br />

Description: Converts a value to the local time.<br />

Include: <br />

Prototype: struct tm *localtime(const time_t *tod);<br />

Argument: tod pointer to stored time<br />

Return Value: Returns the address ofthe time structure.<br />

Remarks: By default, MPLAB C30 returns the timeas instruction cycles. With<br />

this<br />

default localtimeand gmtimewill be equivalent except localtime<br />

will return tm_isdst(Daylight Savings Time flag) as -1 to indicate that<br />

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

Example: #include /* for localtime, */<br />

/* asctime, time_t, tm */<br />

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

int main(void)<br />

{<br />

time_t timer;<br />

struct tm *newtime;<br />

timer = 1066668182; /* Mon Oct 20 16:43:02 2003 */<br />

newtime = localtime(&timer);<br />

strftime (Tiếp theo)<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 324<br />

thời gian<br />

Mô tả: Tính thời gian lịch hiện tại.<br />

Bao gồm:<br />

2004 Microchip Technology Inc<br />

Nguyên mẫu: thời gian time_t (time_t * tod);<br />

Đối số: con trỏ tod để vị trí lưu trữ cho thời gian<br />

Quay trở lại giá trị: Trả lại thời gian lịch được mã hóa như là một giá trị time_t.<br />

Ghi chú: Nếu môi trường mục tiêu không thể xác định thời gian, chức năng<br />

trả về -1, vào vai một time_t. Theo mặc định, MPLAB C30 trả về thời gian<br />

như chu kỳ hướng dẫn. Chức năng này là tùy chỉnh. Xem pic30-libs.<br />

Ví dụ: # include / * Thời gian * /<br />

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

dễ bay hơi int i;<br />

int main (void)<br />

{<br />

time_t ve;<br />

thời gian (0); / * Thời gian bắt đầu * /<br />

for (i = 0; i

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

Saved successfully!

Ooh no, something went wrong!