Bug 204529 - struct tm documentation in time.h possibly incorrect
Summary: struct tm documentation in time.h possibly incorrect
Status: Closed DUPLICATE of bug 204530
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-13 19:32 UTC by Michael Cress
Modified: 2021-10-12 03:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Cress 2015-11-13 19:32:20 UTC
In time.h:

struct tm {
	int	tm_sec;		/* seconds after the minute [0-60] */
	int	tm_min;		/* minutes after the hour [0-59] */
	int	tm_hour;	/* hours since midnight [0-23] */
	int	tm_mday;	/* day of the month [1-31] */
	int	tm_mon;		/* months since January [0-11] */
	int	tm_year;	/* years since 1900 */
	int	tm_wday;	/* days since Sunday [0-6] */
	int	tm_yday;	/* days since January 1 [0-365] */
	int	tm_isdst;	/* Daylight Savings Time flag */
	long	tm_gmtoff;	/* offset from UTC in seconds */
	char	*tm_zone;	/* timezone abbreviation */
};

Is the documentation for tm_sec and tm_yday accurate? The range [0-60] for tm_sec yeilds 61 values and [0-365] yields 366 values. Since other values are in sensible ranges (e.g. tm_min -> [0-59]), I'm thinking this is an error. "man 3 gmtime" shows this same struct as well but makes no mention of these ranges being special cases.
Comment 1 Michael Cress 2015-11-13 19:44:53 UTC
Looking at time.h on Linux, I see

struct tm
{
  int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
.
.
.
  int tm_yday;                  /* Days in year.[0-365] */
.
.
}

So, it seems the 0-60 range is due to a leap second. I am assuming that the 0-365 range is due to leap year range also. Can the struct time be modified to include documentation about this for tm_sec and tm_yday?
Comment 2 Felix Johnson 2021-10-12 03:06:31 UTC

*** This bug has been marked as a duplicate of bug 204530 ***