Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit89dba59

Browse files
committed
Fix actively-misleading comments about the contents of struct pg_tm.
pgtime.h documented the PG interpretation of tm_mon right alongsidethe POSIX interpretation of tm_year, with no hint that neithercomment was correct throughout our code.Perhaps someday we ought to switch to using two separate structdefinitions to provide a clearer indication of which semantics arein use where. But I fear the tedium-versus-safety-gain tradeoffwould not be very good.Discussion:https://postgr.es/m/CAJ7c6TOMG8zSNEZtCn5SPe+cCk3Lfxb71ZaQwT2F4T7PJ_t=KA@mail.gmail.com
1 parent388e71a commit89dba59

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
typedefint64pg_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
structpg_tm
2633
{
2734
inttm_sec;
2835
inttm_min;
2936
inttm_hour;
3037
inttm_mday;
31-
inttm_mon;/*origin 1, not 0! */
32-
inttm_year;/*relative to 1900 */
38+
inttm_mon;/*see above */
39+
inttm_year;/*see above */
3340
inttm_wday;
3441
inttm_yday;
3542
inttm_isdst;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp