Time.h

Time.h

In the C and C++ programming languages, time.h (ctime is the recommended header file for C++ programs) is a header file defined in the C Standard Library to declare time and date functions that provide standardized access to time/date manipulation and formatting.

Functions

;char *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.;char* 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.;struct tm* 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.;struct tm* 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.;time_t mktime(struct tm* 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.;time_t time(time_t* timer): Get the current time (number of seconds from the epoch) 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.;size_t strftime(char* s, size_t n, const char* format, const struct tm* tptr): Format tm into a date/time string

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_TCK: Obsolete 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

*
*


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Time — Time, n.; pl. {Times}. [OE. time, AS. t[=i]ma, akin to t[=i]d time, and to Icel. t[=i]mi, Dan. time an hour, Sw. timme. [root]58. See {Tide}, n.] 1. Duration, considered independently of any system of measurement or any employment of terms which… …   The Collaborative International Dictionary of English

  • Time's Up! — is a grassroots environmental group that seeks to promote a more sustainable, less toxic New York City. For 20 years, it has been committed to improving the environment by empowering individuals to become active in their community. In New York… …   Wikipedia

  • Time UK — is a computer retailer set up by the people behind the failed Time Computer Systems.The company is based within the main factory offices at Time Technology Park in Simonstone, near Burnley in Lancashire. The company specializes in providing… …   Wikipedia

  • Time — (t[imac]m), v. t. [imp. & p. p. {Timed} (t[imac]md); p. pr. & vb. n. {Timing}.] 1. To appoint the time for; to bring, begin, or perform at the proper season or time; as, he timed his appearance rightly. [1913 Webster] There is no greater wisdom… …   The Collaborative International Dictionary of English

  • Time — Time, v. i. 1. To keep or beat time; to proceed or move in time. [1913 Webster] With oar strokes timing to their song. Whittier. [1913 Webster] 2. To pass time; to delay. [Obs.] [1913 Webster] …   The Collaborative International Dictionary of English

  • Time U.K — was an English rock band in the early 1980s. After the split of The Jam in 1982, Drummer Rick Buckler received numerous demo tapes from musicians interested in forming a new band with him. One of these stood out. It was from former Masterswitch… …   Wikipedia

  • Time FM — could meanany of the following radio stations operated by the Sunrise Radio Group:* Time 106.6 * Time 106.8 * Time 107.3 * Time 107.5 …   Wikipedia

  • Time's Up — may refer to:Music* Time s Up (Living Colour album), an album by the band Living Colour. * Time s Up (K Solo album), an album by the American rapper K Solo. * Time s Up (Thee Majesty album), an album by Thee Majesty released in 1999.Television* …   Wikipedia

  • Time — This article is about the measurement. For the magazine, see Time (magazine). For other uses, see Time (disambiguation). The flow of sand in an hourglass can be used to keep track of elapsed time. It also concretely represents the present as… …   Wikipedia

  • time — See: ABOUT TIME, AGAINST TIME, AT A TIME, AT ONE TIME, AT THE SAME TIME, AT TIMES, BEHIND THE TIMES, BEHIND TIME, BIDE ONE S TIME, BIG TIME, EVERY TIME ONE TURNS AROUND, FOR THE TIME BEING, FROM TIME TO TIME, GIVE A HARD TIME, HAVE A TIME, HIGH… …   Dictionary of American idioms

  • time — See: ABOUT TIME, AGAINST TIME, AT A TIME, AT ONE TIME, AT THE SAME TIME, AT TIMES, BEHIND THE TIMES, BEHIND TIME, BIDE ONE S TIME, BIG TIME, EVERY TIME ONE TURNS AROUND, FOR THE TIME BEING, FROM TIME TO TIME, GIVE A HARD TIME, HAVE A TIME, HIGH… …   Dictionary of American idioms

Share the article and excerpts

Direct link
https://en-academic.com/dic.nsf/enwiki/2684492 Do a right-click on the link above
and select “Copy Link”