[PATCH] Change missleading comment for tm_mon field of pg_tm structure

From: Dmitry Fedin <dmitry(dot)fedin(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Change missleading comment for tm_mon field of pg_tm structure
Date: 2017-01-19 19:52:13
Message-ID: CAPZVg5jk8y6+5Ehm=POwChzVr9Jm=4btW7LshgLDhsDogJ0WaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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;

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2017-01-19 20:31:47 Re: [HACKERS] SEGFAULT in HEAD with replication
Previous Message Robert Haas 2017-01-19 19:29:57 Re: Parallel Index Scans