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

Commit4885dab

Browse files
committed
Eliminate unnecessary dependency on mktime(), and consequent 'Unable to
convert date to tm' failures, by using DetermineLocalTimeZone() instead.
1 parentc917660 commit4885dab

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

‎src/backend/utils/adt/date.c

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.70 2002/08/04 06:44:47 thomas Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.71 2002/09/03 19:41:28 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -337,45 +337,32 @@ date_timestamptz(PG_FUNCTION_ARGS)
337337
TimestampTzresult;
338338
structtmtt,
339339
*tm=&tt;
340-
time_tutime;
341340

342-
j2date((dateVal+date2j(2000,1,1)),&(tm->tm_year),&(tm->tm_mon),&(tm->tm_mday));
341+
j2date((dateVal+date2j(2000,1,1)),
342+
&(tm->tm_year),&(tm->tm_mon),&(tm->tm_mday));
343343

344344
if (IS_VALID_UTIME(tm->tm_year,tm->tm_mon,tm->tm_mday))
345345
{
346-
#if defined(HAVE_TM_ZONE)|| defined(HAVE_INT_TIMEZONE)
346+
inttz;
347+
347348
tm->tm_hour=0;
348349
tm->tm_min=0;
349350
tm->tm_sec=0;
350-
tm->tm_isdst=-1;
351-
352-
tm->tm_year-=1900;
353-
tm->tm_mon-=1;
354-
utime=mktime(tm);
355-
if (utime==-1)
356-
elog(ERROR,"Unable to convert date to tm");
351+
tz=DetermineLocalTimeZone(tm);
357352

358353
#ifdefHAVE_INT64_TIMESTAMP
359-
result= ((utime*INT64CONST(1000000))
360-
+ ((date2j(1970,1,1)-date2j(2000,1,1))*INT64CONST(86400000000)));
361-
#else
362-
result=utime+ ((date2j(1970,1,1)-date2j(2000,1,1))*86400.0);
363-
#endif
364-
#else
365-
#ifdefHAVE_INT64_TIMESTAMP
366-
result= ((dateVal*INT64CONST(86400000000))
367-
+ (CTimeZone*INT64CONST(1000000)));
354+
result= (dateVal*INT64CONST(86400000000))
355+
+ (tz*INT64CONST(1000000));
368356
#else
369-
result=dateVal*86400.0+CTimeZone;
370-
#endif
357+
result=dateVal*86400.0+tz;
371358
#endif
372359
}
373360
else
374361
{
362+
/* Outside of range for timezone support, so assume UTC */
375363
#ifdefHAVE_INT64_TIMESTAMP
376364
result= (dateVal*INT64CONST(86400000000));
377365
#else
378-
/* Outside of range for timezone support, so assume UTC */
379366
result=dateVal*86400.0;
380367
#endif
381368
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp