Prepared By : Uday Shah - HOD (IT)
Contact No : 7600044051
--------------------------------------------------------------------------------------------------------------------------
String Library Function
Clock
Returns
number of clock ticks since program start
Declaration:
clock_t
clock(void);
Remarks:
clock
can be used to determine the time interval between two events.
To determine the time in
seconds, divide the value returned by clock by the
value of the macro CLK_TCK.
Difftime
Computes
difference between 2 times
Declaration:
double
difftime(time_t time2, time_t time1);
Remarks:
difftime
calculates the elapsed time in seconds, from time1 to time2.
Return Value:
Returns
the result of its calculation, as a double.
Mktime
Converts
time to calendar format
Declaration:
time_t
mktime(struct tm *t);
Remarks:
Converts the time in the structure *t into a calendar
time with the same format used by the time function. The original values of the
fields tm_sec, tm_min, tm_hour, tm_mday, and tm_mon are not restricted to the
ranges described in the tm structure.
If the fields are not in their proper ranges, mktime
adjusts them. mktime computes values for the fields tm_wday and tm_yday after
the other fields have been adjusted.
Time & Stime
time
gets time of day
stime
sets system date and time
Declaration:
time_t
time(time_t *timer);
int
stime(time_t *tp);
Remarks:
time gives the current time, in seconds, elapsed since
00:00:00 GMT, January 1, 1970. It stores that value in the location *timer,
provided that timer is not a null pointer.
stime sets the system time and date, measured in
seconds from 00:00:00 GMT, January 1, 1970. tp points to the value of the time.
Asctime & Ctime
asctime
converts date and time to ASCII
ctime
converts date and time to a string
Declaration:
char
*asctime(const struct tm *tblock);
char
*ctime(const time_t *time);
Remarks:
asctime converts a time stored as a structure in
*tblock to a 26 character string.
ctime
converts the time value *time into a 26-character string.
Gmtime & Localtime
gmtime
converts date and time to Greenwich Mean Time (GMT)
localtime
converts date and time to a structure
Declaration:
struct
tm *gmtime(const time_t *timer);
struct
tm *localtime(const time_t *timer);
Remarks:
Both functions accept the address of a value returned
by time and return a pointer to a tm structure containing the broken-down time.
gmtime converts directly to GMT; localtime corrects
for the time zone and possible daylight saving time.
Strftime
Formats
time for output
Declaration:
size_t
_cdecl strftime(char *s, size_t maxsize, const char *fmt,
const
struct tm *t);
Remarks:
strftime
formats the time in *t into the array *s according to the format specifications
(a format string) in *fmt.
Return Value:
On
success, strftime returns the number of characters placed into s.
On
error (if the number of characters required > maxsize), returns 0.