开发者

Time terminology

I'm a bit lost with time terminology.

I understand 开发者_开发百科what epoch is and the difference between GMT and UTC.

However I'm a bit confused about the following notations:

  • calendar time
  • local time
  • wall time

How are these related to timezones and daylight savings?

P.S. Good link (thanks to @ZincX)


  • Calendar time is the time that has elapsed since the epoch (t - E).
  • Local time is calendar time corrected for the timezone and DST.
  • Wall time: I assume you mean wallclock time. This it the time elapsed since a process or job has started running.

RTFM time(7), localtime(3), time(1).


Epoch: Used to refer to the beginning of something. such as the Unix Epoch which is of 00:00 , January 1, 1970 UTC. (i.e. a time_t with the value 0 represents midnight, Jan 1. 1970 UTC)

calendar time: the time since the epoch

local time: the calendar time in the timezone you (or the computer) resides in.

wall time: time elapsed on a real clock since some arbitary start , e.g. since you started a program (as opposed to e.g. CPU time used by a program since it started)


Try info and then * Date input formats: (coreutils)Date input formats. which starts with this wonderful text:

Our units of temporal measurement, from seconds on up to months, are so complicated, asymmetrical and disjunctive so as to make coherent mental reckoning in time all but impossible. Indeed, had some tyrannical god contrived to enslave our minds to time, to make it all but impossible for us to escape subjection to sodden routines and unpleasant surprises, he could hardly have done better than handing down our present system. It is like a set of trapezoidal building blocks, with no vertical or horizontal surfaces, like a language in which the simplest thought demands ornate constructions, useless particles and lengthy circumlocutions. Unlike the more successful patterns of language and science, which enable us to face experience boldly or at least level-headedly, our system of temporal calculation silently and persistently encourages our terror of time.

... It is as though architects had to measure length in feet, width in meters and height in ells; as though basic instruction manuals demanded a knowledge of five different languages. It is no wonder then that we often look into our own immediate past or future, last Tuesday or a week from Sunday, with feelings of helpless confusion. ...

-- Robert Grudin, `Time and the Art of Living'.


Calendar time is the time since epoch time. This can be represented in a few ways including:

  1. simple calendar time: number of seconds since epoch
  2. high-resolution calendar time: this uses a struct timeval datatype to include fractions of seconds too.

Local time: this is also a structure (the struct tm data type) which includes calendar time as well as timezone and DST information. This gives all the information to present a time string understandable in a certain locale.

Wall time: time elapsed during the running of your process.

I recommend reading the information at this link. It helped me.


Also take a look at this question for a good explanation of calendar time and local time with code examples written in C :

How do I use the C date and time functions on UNIX?


A bit nit-picky, but there is no such thing as GMT anymore. That term was deprecated almost 40 years ago.

There are many different time standards, UTC being one of them. Another is UT1, which is essentially time as measured by a sundial. Yet another is TAI, International Atomic Time (the real acronym is in French, as are most of the acronyms for the various time standards). TAI, as the name suggests, is time as measured by an atomic clock. UTC is a compromise between TAI and UT1. We want our time scale to stay more or less in sync with the sun, but we also want it to be based on the best definition at hand for a second. There is a tension between these two desires because the Earth does not rotate at a constant rate.

Over the long term, the Earth's rotation rate is slowing down because of the tides. The length of a day was considerably shorter a couple of billion years ago. It was a tiny bit shorter a couple of hundred years ago. Our 86,400 second-long day is based on the length of a solar day from a couple of hundred years ago. Today a solar day is about 86,400.002 seconds long, so we have to add leap seconds every so often to keep midnight more or less at midnight.

As far as the specific questions you asked,

  • It is now 4:25 PM CDT on June 8, 2011. That's calendar time. Here's a challenge: How many second elapsed between 12:42 AM EST on January 3, 1999 and 4:25 PM CDT on June 8, 2011? That's akin to asking someone to do arithmetic in Roman numerals. Yech.

  • Local time: 4:25 PM CDT and 12:42 AM EST are examples of local time. What is midnight to me is noon to someone halfway around the world.

  • Wall time (Better: Wall clock time): Suppose you run a program and it takes 20 minutes to run to completion. That 20 minutes is the wall clock time it took the program to run this time around. When I see some program take a lot longer than expected to run I check to see if my stupid antivirus program has gone viral. Oftentimes that is exactly what happens. After giving the antivirus program a kick in the pants, that exact same program run might take only five minutes of wall clock time. The CPU time, on the other hand, will be pretty much the same over the two runs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜