Just curious. I've tended to name variables of the type struct tm
something like time_bits
or similar, since it contains the broken-down calendar time bits. Most of the documentation I've seen refers to this type as 'calendar time', as opposed to 'clock time' or 'epoch seconds' for time_t
.
Asked
Active
Viewed 765 times
-4

Huckle
- 1,810
- 3
- 26
- 40
-
1You will want to certainly read [C Date Time tutorial](http://zetcode.com/articles/cdatetime/) – David C. Rankin Dec 25 '17 at 01:55
-
@DavidC.Rankin That was a good read. Concise and informative. It did however completely mis-represent the POSIX representation of UTC (which is lacking leap seconds - so it's fine for reading the time but not for measuring long spans of it). The only good reference I've found for that is [Olsen's / the IANA's timezone database](https://github.com/eggert/tz/blob/04394af38a9d08fc6655466dfd8d4cf47025893d/time2posix.3#L26-L32) and associated `libtz.a` – Huckle Dec 26 '17 at 21:48
-
Point well taken, but for a full understanding of *time* and *calendars* [Calendars - Explanatory Supplement to the Astronomical Almanac (uspno.navy.mil)](http://aa.usno.navy.mil/publications/docs/c15_usb_online.pdf) is a good starting point. Planetary positions from an astronomical standpoint, require the most precision of just about all time application (outside of relativistic effects). – David C. Rankin Dec 27 '17 at 03:20
-
There's simply no sound rationale for a lot of the things in the standard library, including naming. When C was standardized, they simply picked various functions from here and there in the Unix code base and gave them "standard library" status. Even if the functions were messy and poorly designed. As for what kind of Unix dinosaur that once invented `struct tm` and why they named things as they did, is not mentioned in the C rationale. This all goes back to early 70s. – Lundin Jan 09 '18 at 10:32
2 Answers
3
It almost certainly just stands for "time". The ISO standard describes it as a thing:
... which holds the components of a calendar time, called the broken-down time.

paxdiablo
- 854,327
- 234
- 1,573
- 1,953
3
If it were named struct time
, a lot of people would confuse it with this function:
time_t time(time_t *);
Although in C structure tags don't interfere with variable/function names, having different names for them reduces confusion.

iBug
- 35,554
- 7
- 89
- 134