Time t

Time t

The time_t datatype is a data type in the ISO C library defined for storing system time values. Such values are returned from the standard time() library function. This type is a typedef defined in the standard <time.h> header.
ISO C defines time_t as an arithmetic type, but does not specify any particular type, range, resolution, or encoding for it. Also unspecified are the meanings of arithmetic operations applied to time values.

Unix and POSIX-compliant systems implement the time_t type as a signed integer (typically 32 or 64 bits wide) which represents the number of seconds since the start of the Unix epoch: midnight UTC of January 1 1970 (not counting leap seconds). Some systems support negative time values, while others do not. 32 bit time_t is deprecated, due to the Year 2038 problem. [ [http://pw1.netcom.com/~rogermw/Y2038.html The Year 2038 problem] , Roger M. Wilcox. Retrieved on 2008-05-19.]

In addition to the time() function, ISO C also specifies other functions and types for converting time_t system time values into calendar times and vice versa.

Example

The following C code retrieves the current time, formats it as a string, and writes it to the standard output.


#include
#include

/*
* The result should look something like
* Fri 2008-08-22 15:21:59 WAST
*/

int main(void){ time_t now; struct tm *ts; char buf [80] ;

// Get the current time now = time(NULL);

// Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" ts = localtime(&now); strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts); printf("%s ", buf);

return 0;}

time_t parties

Unix enthusiasts have a history of holding time_t parties to celebrate significant values of the Unix time number. [cite web |url=http://slashdot.org/articles/05/03/17/169200.shtml?tid=130 |title=Slashdot ! date +%s Turning 1111111111 |accessdate=2007-07-14 |format= |work= ] These are directly analogous to the new year celebrations that occur at the change of year in many calendars. As the use of Unix time has spread, so has the practice of celebrating its milestones. Usually it is time values that are round numbers in decimal that are celebrated, following the Unix convention of viewing time_t values in decimal. Among some groups round binary numbers are also celebrated, such as +230 which occurred at 13:37:04 UTC on January 10, 2004.

The events that these celebrate are typically described as "N seconds since the Unix epoch", but this is inaccurate. As discussed above, due to the handling of leap seconds in Unix time, the number of seconds elapsed since the Unix epoch is slightly greater than the Unix time number, for times later than the epoch.

At 01:46:40 UTC on September 9, 2001, the Unix billennium (Unix time number 1000000000) was celebrated.

At 01:58:31 UTC on March 18, 2005, the Unix time number reached 1111111111.

At 23:31:30 UTC on February 13, 2009, a celebration is expected as the Unix time number reaches 1234567890 seconds. This day happens to fall on Friday the 13th on the Gregorian calendar. The UNIX time number 0x50000000 (1342177280 seconds) will also happen on a Friday the 13th, at 11:01:20 UTC on July 13, 2012.

At 03:33:20 UTC on May 18 2033, the second billennium will be celebrated (Unix time number 2000000000).

ee also

* C standard library
* Real-time clock
* System time
* Unix time
* Year 2038 problem

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 — (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 — 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

  • time — I. noun Etymology: Middle English, from Old English tīma; akin to Old Norse tīmi time, Old English tīd more at tide Date: before 12th century 1. a. the measured or measurable period during which an action, process, or condition exists or… …   New Collegiate Dictionary

  • Time³ — Infobox Album | Name = Time3 Type = Compilation album Artist = Journey Released = December 1, 1992 Recorded = May 1976 Aug 1985 Genre = Rock Length = Disc 1: 73:39 Disc 2: 76:31 Disc 3: 78:21 Label = Columbia Producer = Don DeVito Reviews = *… …   Wikipedia

  • Time ball — 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… …   The Collaborative International Dictionary of English

  • Time bargain — 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… …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”