Time.h Article Index for
Time.h
Articles about
Time.h
 

Information About

Time.h




In Computer Programming , time.h is a header file defined in the C Standard Library to provide standardized access to Time And Date functions.


FUNCTIONS


  • asctime( Const Struct tm--- tmptr)

  • : Convert tm to a string in the format "Www Mmm dd hh:mm:ss yyyy", where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year. The string is followed by a Newline and a terminating Null Character , containing a total of 26 characters. The string pointed at is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the contents of the string is overwritten.

;clock_t clock(void)
: Return number of clock ticks since process start.
  • ctime( Const time_t--- timer)

  • : Convert Time_t time value to string in the same format as asctime. The string pointed is statically allocated and shared by ctime and asctime functions. Each time one of these functions is called the content of the string is overwritten. ctime also uses internally the buffer used by gmtime and localtime as return value, so a call to this function will overwrite this.

;double difftime( Time_t timer2, Time_t timer1)
: Returns the difference in seconds between the two times.
  • gmtime( Const time_t--- timer)

  • : Convert a Time_t value to a tm structure as UTC time. This structure is statically allocated and shared by gmtime, localtime and ctime functions. Each time one of these functions is called the content of the structure is overwritten.

  • localtime( Const time_t--- timer)

  • : Convert a Time_t time value to a tm structure as local time. This structure is statically allocated and shared by gmtime, localtime and ctime functions. Each time one of these functions is called the content of the structure is overwritten.

  • ptm)

  • : Convert tm to a Time_t time value. Checks the members of the tm structure passed as parameter ptm adjusting the values if the ones provided are not in the possible range or they are incomplete or mistaken and then translates that structure to a Time_t value that is returned. The original values of tm_wday and tm_yday members of ptm are ignored and filled with the correspondent ones to the calculated date. The range of tm_mday is not checked until tm_mon and tm_year are determined. On error, a -1 value is returned.

  • timer)

  • : Get the current time from the system clock. Stores that value in timer. If timer is null, the value is not stored, but it is still returned by the function.




CONSTANTS

;CLK_PER_SEC
: Constant that defines the number of clock ticks per second. Used by the clock() function.
;CLOCKS_PER_SEC
: An alternative name for CLK_PER_SEC used in its place in some libraries
;CLK_TICK
: Usually a macro for CLK_PER_SEC


DATA TYPES

;clock_t
: Data type returned by clock().
Generally defined as long int.
; Time_t
: Data type returned by time().
Generally defined as long int.
; Struct tm
: A non-linear, broken-down calendar representation of time.


Calendar time

Calendar time in the C standard library is represented as the Struct tm structure, consisting of the following attributes:


REFERENCES