简体   繁体   English

“struct tm”中的“tm”代表什么?

[英]What does the 'tm' in `struct tm` stand for?

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.我倾向于将struct tm类型的变量命名为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 .我见过的大多数文档都将这种类型称为“日历时间”,而不是time_t “时钟时间”或“纪元秒”。

It almost certainly just stands for "time".它几乎可以肯定只是代表“时间”。 The ISO standard describes it as a thing: ISO 标准将其描述为:

... which holds the components of a calendar time, called the broken-down time. ...它包含日历时间的组成部分,称为分解时间。

If it were named struct time , a lot of people would confuse it with this function:如果它被命名为struct time ,很多人会将它与这个函数混淆:

time_t time(time_t *);

Although in C structure tags don't interfere with variable/function names, having different names for them reduces confusion.尽管在 C 结构中标签不会干扰变量/函数名称,但为它们使用不同的名称可以减少混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM