Standard C Libraries -. More...
Go to the source code of this file.
Data Structures | |
struct | tm |
Macros | |
#define | size_t |
#define | CLOCKS_PER_SEC |
Functions | |
struct tm | asctime (const struct tm *tptr) |
clock_t | clock (void) |
char * | ctime (const time_t *tod) |
double | difftime (time_t t1, time_t t0) |
struct tm * | gmtime (const time_t *tod) |
struct tm * | localtime (const time_t *tod) |
time_t | mktime (struct tm *tptr) |
Variables | |
int | tm_sec |
int | tm_min |
int | tm_hour |
int | tm_mday |
int | tm_mon |
int | tm_year |
int | tm_wday |
int | tm_yday |
int | tm_isdst |
Standard C Libraries -.
The header file, time.h, consists of types, macros and functions that manipulate time.
The documentation in this header file has been copied from the documentation provided with the Microchip MPLAB XC16 compiler. The original lincense agreement included with the XC16 compiler applies!
#define size_t |
Description: Represents calendar time values.
Include: <time.h> Description: Number of processor clocks per second.
Include: <time.h>
Value: 1
Remarks:
The compiler returns clock ticks (instruction cycles) not actual time. Description: The value of a null pointer constant.
Include: <time.h> Description: Converts the time structure to a character string.
Include: <time.h>
tptr | time/date structure |
Example:
Output:
Day and time is Sat Feb 1 02:30:30 2003
clock_t clock | ( | void | ) |
Description: Calculates the processor time.
Include: <time.h>
Remarks:
If the target environment cannot measure elapsed processor time, the function returns -1, cast as a clock_t. (i.e. (clock_t) -1).
By default, the 16-bit compiler returns the time as instruction cycles.
Example:
Output:
start = 0
stop = 317
char* ctime | ( | const time_t * | tod) |
Description: Converts calendar time to a string representation of local time.
Include: <time.h>
tod | pointer to stored time |
Remarks:
This function is equivalent to asctime(localtime(tod)).
Example:
Output:
Day and time Sat Feb 1 02:30:30 2003
double difftime | ( | time_t | t1, |
time_t | t0 | ||
) |
Description: Find the difference between two times.
Include: <time.h>
t1 | ending time |
t0 | beginning time |
Remarks:
By default, the 16-bit compiler returns the time as instruction cycles so difftime returns the number of ticks between t1 and t0.
Example:
Output:
start = 0
stop = 317
Elapsed time = 317
struct tm* gmtime | ( | const time_t * | tod) |
Description: Converts calendar time to time structure expressed as Universal Time Coordinated (UTC) also known as Greenwich Mean Time (GMT).
Include: <time.h>
tod | pointer to stored time |
Remarks:
This function breaks down the tod value into the time structure of type tm. By default, the 16-bit compiler returns the time as instruction cycles. With this default, gmtime and localtime will be equivalent, except gmtime will return tm_isdst (Daylight Savings Time flag) as zero to indicate that Daylight Savings Time is not in effect.
Example:
Output:
UTC time = Mon Oct 20 16:43:02 2003
struct tm* localtime | ( | const time_t * | tod) |
Description: Converts a value to the local time.
Include: <time.h>
tod | pointer to stored time |
Remarks:
By default, the 16-bit compiler returns the time as instruction cycles. With this default, localtime and gmtime will be equivalent, except localtime will return tm_isdst (Daylight Savings Time flag) as -1 to indicate that the status of Daylight Savings Time is not known.
Example:
Output:
Local time = Mon Oct 20 16:43:02 2003
time_t mktime | ( | struct tm * | tptr) |
Description: Converts local time to a calendar value.
Include: <time.h>
tptr | a pointer to the time structure |
Remarks:
If the calendar time cannot be represented, the function returns -1, cast as a time_t (i.e. (time_t) -1).
Example:
Output:
Local time = Mon Oct 20 16:43:02 2003
Calendar time as time_t = 1066668182