Thread: [HACKERS] [PATCH] Change missleading comment for tm_mon field of pg_tm structure
[HACKERS] [PATCH] Change missleading comment for tm_mon field of pg_tm structure
From
Dmitry Fedin
Date:
According to usages, tm_mon (month) field has origin 1, not 0. This is difference from C-library version of struct tm, which has origin 0 for real. For example: ```C if (DateOrder == DATEORDER_DMY) sprintf(str, "%02d/%02d", tm->tm_mday, tm->tm_mon); else sprintf(str, "%02d/%02d", tm->tm_mon, tm->tm_mday); in src/backend/utils/adt/datetime.c ``` ---src/include/pgtime.h | 2 +-1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/pgtime.h b/src/include/pgtime.h index dcd0730..52b54b9 100644 --- a/src/include/pgtime.h +++ b/src/include/pgtime.h @@ -28,7 +28,7 @@ struct pg_tm int tm_min; int tm_hour; int tm_mday; - int tm_mon; /* origin 0, not 1 */ + int tm_mon; /* origin 1, not 0! */ int tm_year; /* relative to 1900 */ int tm_wday; int tm_yday;
Re: [HACKERS] [PATCH] Change missleading comment for tm_mon field ofpg_tm structure
From
Robert Haas
Date:
On Thu, Jan 19, 2017 at 2:52 PM, Dmitry Fedin <dmitry.fedin@gmail.com> wrote: > According to usages, tm_mon (month) field has origin 1, not 0. This is > difference from C-library version of struct tm, which has origin 0 for > real. Hmm, thanks for noticing. Looks like it has been wrong for a really long time. Your patch got garbled; it had two-space indents instead of tabs, so it didn't apply. It's best to attach them rather than including them inline. Committed. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company