Content-Length: 281439 | pFad | http://github.com/postgrespro/postgres/commit/89dba59590fdd03799a47daf8019890d4324fbcf

86 Fix actively-misleading comments about the contents of struct pg_tm. · postgrespro/postgres@89dba59 · GitHub
Skip to content

Commit 89dba59

Browse files
committed
Fix actively-misleading comments about the contents of struct pg_tm.
pgtime.h documented the PG interpretation of tm_mon right alongside the POSIX interpretation of tm_year, with no hint that neither comment was correct throughout our code. Perhaps someday we ought to switch to using two separate struct definitions to provide a clearer indication of which semantics are in use where. But I fear the tedium-versus-safety-gain tradeoff would not be very good. Discussion: https://postgr.es/m/CAJ7c6TOMG8zSNEZtCn5SPe+cCk3Lfxb71ZaQwT2F4T7PJ_t=KA@mail.gmail.com
1 parent 388e71a commit 89dba59

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/include/pgtime.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@
2222

2323
typedef int64 pg_time_t;
2424

25+
/*
26+
* CAUTION: the IANA timezone library (src/timezone/) follows the POSIX
27+
* convention that tm_mon counts from 0 and tm_year is relative to 1900.
28+
* However, Postgres' datetime functions generally treat tm_mon as counting
29+
* from 1 and tm_year as relative to 1 BC. Be sure to make the appropriate
30+
* adjustments when moving from one code domain to the other.
31+
*/
2532
struct pg_tm
2633
{
2734
int tm_sec;
2835
int tm_min;
2936
int tm_hour;
3037
int tm_mday;
31-
int tm_mon; /* origen 1, not 0! */
32-
int tm_year; /* relative to 1900 */
38+
int tm_mon; /* see above */
39+
int tm_year; /* see above */
3340
int tm_wday;
3441
int tm_yday;
3542
int tm_isdst;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/89dba59590fdd03799a47daf8019890d4324fbcf

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy