Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
4550c1e5
Commit
4550c1e5
authored
May 23, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More macro cleanups for date/time.
parent
5ebaae80
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
98 additions
and
88 deletions
+98
-88
src/backend/utils/adt/date.c
src/backend/utils/adt/date.c
+15
-15
src/backend/utils/adt/datetime.c
src/backend/utils/adt/datetime.c
+8
-8
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/nabstime.c
+10
-10
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+12
-12
src/include/utils/timestamp.h
src/include/utils/timestamp.h
+3
-1
src/interfaces/ecpg/pgtypeslib/datetime.c
src/interfaces/ecpg/pgtypeslib/datetime.c
+2
-2
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt.h
+8
-0
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/dt_common.c
+8
-8
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/interval.c
+14
-14
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
+16
-16
src/timezone/pgtz.c
src/timezone/pgtz.c
+2
-2
No files found.
src/backend/utils/adt/date.c
View file @
4550c1e5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.10
6 2005/05/23 18:56:55
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.10
7 2005/05/23 21:54:01
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1339,8 +1339,8 @@ timestamp_time(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
/*
* Could also do this with time = (timestamp /
86400000000
*
*
86400000000
) - timestamp;
* Could also do this with time = (timestamp /
USECS_PER_DAY
*
*
USECS_PER_DAY
) - timestamp;
*/
result
=
((((((
tm
->
tm_hour
*
60
)
+
tm
->
tm_min
)
*
60
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
);
...
...
@@ -1376,8 +1376,8 @@ timestamptz_time(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
/*
* Could also do this with time = (timestamp /
86400000000
*
*
86400000000
) - timestamp;
* Could also do this with time = (timestamp /
USECS_PER_DAY
*
*
USECS_PER_DAY
) - timestamp;
*/
result
=
((((((
tm
->
tm_hour
*
60
)
+
tm
->
tm_min
)
*
60
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
);
...
...
@@ -1498,7 +1498,7 @@ time_pl_interval(PG_FUNCTION_ARGS)
result
=
(
time
+
span
->
time
);
TMODULO
(
result
,
time1
,
(
double
)
SECS_PER_DAY
);
if
(
result
<
0
)
result
+=
86400
;
result
+=
SECS_PER_DAY
;
#endif
PG_RETURN_TIMEADT
(
result
);
...
...
@@ -1525,7 +1525,7 @@ time_mi_interval(PG_FUNCTION_ARGS)
result
=
(
time
-
span
->
time
);
TMODULO
(
result
,
time1
,
(
double
)
SECS_PER_DAY
);
if
(
result
<
0
)
result
+=
86400
;
result
+=
SECS_PER_DAY
;
#endif
PG_RETURN_TIMEADT
(
result
);
...
...
@@ -2033,7 +2033,7 @@ timetz_pl_interval(PG_FUNCTION_ARGS)
result
->
time
=
(
time
->
time
+
span
->
time
);
TMODULO
(
result
->
time
,
time1
.
time
,
(
double
)
SECS_PER_DAY
);
if
(
result
->
time
<
0
)
result
->
time
+=
86400
;
result
->
time
+=
SECS_PER_DAY
;
#endif
result
->
zone
=
time
->
zone
;
...
...
@@ -2066,7 +2066,7 @@ timetz_mi_interval(PG_FUNCTION_ARGS)
result
->
time
=
(
time
->
time
-
span
->
time
);
TMODULO
(
result
->
time
,
time1
.
time
,
(
double
)
SECS_PER_DAY
);
if
(
result
->
time
<
0
)
result
->
time
+=
86400
;
result
->
time
+=
SECS_PER_DAY
;
#endif
result
->
zone
=
time
->
zone
;
...
...
@@ -2504,9 +2504,9 @@ timetz_zone(PG_FUNCTION_ARGS)
#else
result
->
time
=
time
->
time
+
(
time
->
zone
-
tz
);
while
(
result
->
time
<
0
)
result
->
time
+=
86400
;
while
(
result
->
time
>=
86400
)
result
->
time
-=
86400
;
result
->
time
+=
SECS_PER_DAY
;
while
(
result
->
time
>=
SECS_PER_DAY
)
result
->
time
-=
SECS_PER_DAY
;
#endif
result
->
zone
=
tz
;
...
...
@@ -2558,9 +2558,9 @@ timetz_izone(PG_FUNCTION_ARGS)
#else
result
->
time
=
time
->
time
+
(
time
->
zone
-
tz
);
while
(
result
->
time
<
0
)
result
->
time
+=
86400
;
while
(
result
->
time
>=
86400
)
result
->
time
-=
86400
;
result
->
time
+=
SECS_PER_DAY
;
while
(
result
->
time
>=
SECS_PER_DAY
)
result
->
time
-=
SECS_PER_DAY
;
#endif
result
->
zone
=
tz
;
...
...
src/backend/utils/adt/datetime.c
View file @
4550c1e5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.14
2 2005/05/23 18:56:55
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.14
3 2005/05/23 21:54:01
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1214,7 +1214,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#else
dt2time
(
time
*
86400
,
&
tm
->
tm_hour
,
dt2time
(
time
*
SECS_PER_DAY
,
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#endif
}
...
...
@@ -1611,8 +1611,8 @@ DetermineLocalTimeZone(struct pg_tm * tm)
goto
overflow
;
date
=
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
)
-
UNIX_EPOCH_JDATE
;
day
=
((
pg_time_t
)
date
)
*
86400
;
if
(
day
/
86400
!=
date
)
day
=
((
pg_time_t
)
date
)
*
SECS_PER_DAY
;
if
(
day
/
SECS_PER_DAY
!=
date
)
goto
overflow
;
sec
=
tm
->
tm_sec
+
(
tm
->
tm_min
+
tm
->
tm_hour
*
60
)
*
60
;
mytime
=
day
+
sec
;
...
...
@@ -1972,7 +1972,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
dt2time
(
time
*
USECS_PER_DAY
,
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#else
dt2time
(
time
*
86400
,
dt2time
(
time
*
SECS_PER_DAY
,
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#endif
}
...
...
@@ -3099,7 +3099,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
{
int
sec
;
fval
*=
86400
;
fval
*=
SECS_PER_DAY
;
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -3117,7 +3117,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
{
int
sec
;
fval
*=
(
7
*
86400
);
fval
*=
(
7
*
SECS_PER_DAY
);
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -3135,7 +3135,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
{
int
sec
;
fval
*=
(
30
*
86400
);
fval
*=
(
30
*
SECS_PER_DAY
);
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
src/backend/utils/adt/nabstime.c
View file @
4550c1e5
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.1
29 2005/05/23 18:56:55
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.1
30 2005/05/23 21:54:02
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -129,10 +129,10 @@ AbsoluteTimeUsecToTimestampTz(AbsoluteTime sec, int usec)
TimestampTz
result
;
#ifdef HAVE_INT64_TIMESTAMP
result
=
((
sec
-
((
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
86400
))
result
=
((
sec
-
((
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
SECS_PER_DAY
))
*
USECS_PER_SEC
)
+
usec
;
#else
result
=
sec
-
((
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
86400
)
result
=
sec
-
((
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
SECS_PER_DAY
)
+
(
usec
/
1000000
.
0
);
#endif
...
...
@@ -730,7 +730,7 @@ reltimein(PG_FUNCTION_ARGS)
{
case
DTK_DELTA
:
result
=
((((
tm
->
tm_hour
*
60
)
+
tm
->
tm_min
)
*
60
)
+
tm
->
tm_sec
);
result
+=
((
tm
->
tm_year
*
36525
*
864
)
+
(((
tm
->
tm_mon
*
30
)
+
tm
->
tm_mday
)
*
86400
));
result
+=
((
tm
->
tm_year
*
36525
*
864
)
+
(((
tm
->
tm_mon
*
30
)
+
tm
->
tm_mday
)
*
SECS_PER_DAY
));
break
;
default:
...
...
@@ -795,7 +795,7 @@ reltime2tm(RelativeTime time, struct pg_tm * tm)
FMODULO
(
dtime
,
tm
->
tm_year
,
31557600
);
FMODULO
(
dtime
,
tm
->
tm_mon
,
2592000
);
FMODULO
(
dtime
,
tm
->
tm_mday
,
86400
);
FMODULO
(
dtime
,
tm
->
tm_mday
,
SECS_PER_DAY
);
FMODULO
(
dtime
,
tm
->
tm_hour
,
3600
);
FMODULO
(
dtime
,
tm
->
tm_min
,
60
);
FMODULO
(
dtime
,
tm
->
tm_sec
,
1
);
...
...
@@ -947,10 +947,10 @@ interval_reltime(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
span
=
((((
INT64CONST
(
365250000
)
*
year
)
+
(
INT64CONST
(
30000000
)
*
month
))
*
INT64CONST
(
86400
))
+
interval
->
time
);
*
INT64CONST
(
SECS_PER_DAY
))
+
interval
->
time
);
span
/=
USECS_PER_SEC
;
#else
span
=
(((((
double
)
365
.
25
*
year
)
+
((
double
)
30
*
month
))
*
86400
)
+
interval
->
time
);
span
=
(((((
double
)
365
.
25
*
year
)
+
((
double
)
30
*
month
))
*
SECS_PER_DAY
)
+
interval
->
time
);
#endif
if
((
span
<
INT_MIN
)
||
(
span
>
INT_MAX
))
...
...
@@ -986,13 +986,13 @@ reltime_interval(PG_FUNCTION_ARGS)
#ifdef HAVE_INT64_TIMESTAMP
year
=
(
reltime
/
(
36525
*
864
));
reltime
-=
(
year
*
(
36525
*
864
));
month
=
(
reltime
/
(
30
*
86400
));
reltime
-=
(
month
*
(
30
*
86400
));
month
=
(
reltime
/
(
30
*
SECS_PER_DAY
));
reltime
-=
(
month
*
(
30
*
SECS_PER_DAY
));
result
->
time
=
(
reltime
*
USECS_PER_SEC
);
#else
TMODULO
(
reltime
,
year
,
(
36525
*
864
));
TMODULO
(
reltime
,
month
,
(
30
*
86400
));
TMODULO
(
reltime
,
month
,
(
30
*
SECS_PER_DAY
));
result
->
time
=
reltime
;
#endif
...
...
src/backend/utils/adt/timestamp.c
View file @
4550c1e5
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.12
1 2005/05/23 18:56:55
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.12
2 2005/05/23 21:54:02
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -699,7 +699,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
USECS_PER_DAY
;
#else
interval
->
time
=
((
int
)
(
interval
->
time
/
86400
))
*
86400
;
interval
->
time
=
((
int
)
(
interval
->
time
/
SECS_PER_DAY
))
*
SECS_PER_DAY
;
#endif
}
else
if
(
range
==
INTERVAL_MASK
(
HOUR
))
...
...
@@ -1021,7 +1021,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn
if
(
time
<
0
)
{
time
+=
86400
;
time
+=
SECS_PER_DAY
;
date
-=
1
;
}
#endif
...
...
@@ -1074,10 +1074,10 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn
*/
#ifdef HAVE_INT64_TIMESTAMP
dt
=
(
dt
-
*
fsec
)
/
USECS_PER_SEC
+
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
86400
;
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
SECS_PER_DAY
;
#else
dt
=
rint
(
dt
-
*
fsec
+
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
86400
);
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
SECS_PER_DAY
);
#endif
utime
=
(
pg_time_t
)
dt
;
if
((
Timestamp
)
utime
==
dt
)
...
...
@@ -1151,7 +1151,7 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
(
*
result
>=
0
&&
date
<
0
))
return
-
1
;
#else
*
result
=
date
*
86400
+
time
;
*
result
=
date
*
SECS_PER_DAY
+
time
;
#endif
if
(
tzp
!=
NULL
)
*
result
=
dt2local
(
*
result
,
-
(
*
tzp
));
...
...
@@ -1621,9 +1621,9 @@ interval_cmp_internal(Interval *interval1, Interval *interval2)
span2
+=
interval2
->
month
*
INT64CONST
(
30
)
*
USECS_PER_DAY
;
#else
if
(
interval1
->
month
!=
0
)
span1
+=
interval1
->
month
*
(
30
.
0
*
86400
);
span1
+=
interval1
->
month
*
(
30
.
0
*
SECS_PER_DAY
);
if
(
interval2
->
month
!=
0
)
span2
+=
interval2
->
month
*
(
30
.
0
*
86400
);
span2
+=
interval2
->
month
*
(
30
.
0
*
SECS_PER_DAY
);
#endif
return
((
span1
<
span2
)
?
-
1
:
(
span1
>
span2
)
?
1
:
0
);
...
...
@@ -2166,7 +2166,7 @@ interval_mul(PG_FUNCTION_ARGS)
result
->
month
=
rint
(
months
);
result
->
time
=
JROUND
(
span1
->
time
*
factor
);
/* evaluate fractional months as 30 days */
result
->
time
+=
JROUND
((
months
-
result
->
month
)
*
30
*
86400
);
result
->
time
+=
JROUND
((
months
-
result
->
month
)
*
30
*
SECS_PER_DAY
);
#endif
PG_RETURN_INTERVAL_P
(
result
);
...
...
@@ -2211,7 +2211,7 @@ interval_div(PG_FUNCTION_ARGS)
result
->
month
=
rint
(
months
);
result
->
time
=
JROUND
(
span
->
time
/
factor
);
/* evaluate fractional months as 30 days */
result
->
time
+=
JROUND
((
months
-
result
->
month
)
*
30
*
86400
);
result
->
time
+=
JROUND
((
months
-
result
->
month
)
*
30
*
SECS_PER_DAY
);
#endif
PG_RETURN_INTERVAL_P
(
result
);
...
...
@@ -3788,8 +3788,8 @@ interval_part(PG_FUNCTION_ARGS)
#endif
if
(
interval
->
month
!=
0
)
{
result
+=
(
365
.
25
*
86400
)
*
(
interval
->
month
/
12
);
result
+=
(
30
.
0
*
86400
)
*
(
interval
->
month
%
12
);
result
+=
(
365
.
25
*
SECS_PER_DAY
)
*
(
interval
->
month
/
12
);
result
+=
(
30
.
0
*
SECS_PER_DAY
)
*
(
interval
->
month
%
12
);
}
}
else
...
...
src/include/utils/timestamp.h
View file @
4550c1e5
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.4
1 2005/05/23 18:56:55
momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.4
2 2005/05/23 21:54:02
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -60,10 +60,12 @@ typedef struct
#define MAX_INTERVAL_PRECISION 6
#define SECS_PER_DAY 86400
#ifdef HAVE_INT64_TIMESTAMP
#define USECS_PER_DAY INT64CONST(86400000000)
#define USECS_PER_HOUR INT64CONST(3600000000)
#define USECS_PER_MINUTE INT64CONST(60000000)
#define USECS_PER_SEC INT64CONST(1000000)
#endif
/*
* Macros for fmgr-callable functions.
...
...
src/interfaces/ecpg/pgtypeslib/datetime.c
View file @
4550c1e5
...
...
@@ -22,10 +22,10 @@ PGTYPESdate_from_timestamp(timestamp dt)
#ifdef HAVE_INT64_TIMESTAMP
/* Microseconds to days */
dDate
=
(
dt
/
INT64CONST
(
86400000000
)
);
dDate
=
(
dt
/
USECS_PER_DAY
);
#else
/* Seconds to days */
dDate
=
(
dt
/
86400
.
0
);
dDate
=
(
dt
/
(
double
)
SECS_PER_DAY
);
#endif
return
dDate
;
...
...
src/interfaces/ecpg/pgtypeslib/dt.h
View file @
4550c1e5
...
...
@@ -216,6 +216,14 @@ do { \
} while(0)
#endif
#define SECS_PER_DAY 86400
#ifdef HAVE_INT64_TIMESTAMP
#define USECS_PER_DAY INT64CONST(86400000000)
#define USECS_PER_HOUR INT64CONST(3600000000)
#define USECS_PER_MINUTE INT64CONST(60000000)
#define USECS_PER_SEC INT64CONST(1000000)
#endif
/*
* Date/time validation
* Include check for leap year.
...
...
src/interfaces/ecpg/pgtypeslib/dt_common.c
View file @
4550c1e5
...
...
@@ -1246,12 +1246,12 @@ dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec)
time
=
jd
;
#ifdef HAVE_INT64_TIMESTAMP
*
hour
=
(
time
/
INT64CONST
(
3600000000
)
);
time
-=
((
*
hour
)
*
INT64CONST
(
3600000000
)
);
*
min
=
(
time
/
INT64CONST
(
60000000
)
);
time
-=
((
*
min
)
*
INT64CONST
(
60000000
)
);
*
sec
=
(
time
/
INT64CONST
(
1000000
)
);
*
fsec
=
(
time
-
(
*
sec
*
INT64CONST
(
1000000
)
));
*
hour
=
(
time
/
USECS_PER_HOUR
);
time
-=
((
*
hour
)
*
USECS_PER_HOUR
);
*
min
=
(
time
/
USECS_PER_MINUTE
);
time
-=
((
*
min
)
*
USECS_PER_MINUTE
);
*
sec
=
(
time
/
USECS_PER_SEC
);
*
fsec
=
(
time
-
(
*
sec
*
USECS_PER_SEC
));
#else
*
hour
=
(
time
/
3600
);
time
-=
((
*
hour
)
*
3600
);
...
...
@@ -1675,7 +1675,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
if
((
tm
->
tm_hour
<
0
)
||
(
tm
->
tm_min
<
0
)
||
(
tm
->
tm_min
>
59
)
||
(
tm
->
tm_sec
<
0
)
||
(
tm
->
tm_sec
>
59
)
||
(
*
fsec
>=
INT64CONST
(
1000000
)
))
||
(
*
fsec
>=
USECS_PER_SEC
))
return
-
1
;
#else
if
((
tm
->
tm_hour
<
0
)
...
...
@@ -2257,7 +2257,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
#ifdef HAVE_INT64_TIMESTAMP
dt2time
((
time
*
USECS_PER_DAY
),
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#else
dt2time
((
time
*
86400
),
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
dt2time
((
time
*
SECS_PER_DAY
),
&
tm
->
tm_hour
,
&
tm
->
tm_min
,
&
tm
->
tm_sec
,
fsec
);
#endif
}
break
;
...
...
src/interfaces/ecpg/pgtypeslib/interval.c
View file @
4550c1e5
...
...
@@ -88,7 +88,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
if
((
tm
->
tm_hour
<
0
)
||
(
tm
->
tm_min
<
0
)
||
(
tm
->
tm_min
>
59
)
||
(
tm
->
tm_sec
<
0
)
||
(
tm
->
tm_sec
>
59
)
||
(
*
fsec
>=
INT64CONST
(
1000000
)
))
||
(
*
fsec
>=
USECS_PER_SEC
))
return
-
1
;
#else
if
((
tm
->
tm_hour
<
0
)
...
...
@@ -296,7 +296,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
{
int
sec
;
fval
*=
86400
;
fval
*=
SECS_PER_DAY
;
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -314,7 +314,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
{
int
sec
;
fval
*=
(
7
*
86400
);
fval
*=
(
7
*
SECS_PER_DAY
);
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -332,7 +332,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
{
int
sec
;
fval
*=
(
30
*
86400
);
fval
*=
(
30
*
SECS_PER_DAY
);
sec
=
fval
;
tm
->
tm_sec
+=
sec
;
#ifdef HAVE_INT64_TIMESTAMP
...
...
@@ -419,8 +419,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
int
sec
;
#ifdef HAVE_INT64_TIMESTAMP
sec
=
(
*
fsec
/
INT64CONST
(
1000000
)
);
*
fsec
-=
(
sec
*
INT64CONST
(
1000000
)
);
sec
=
(
*
fsec
/
USECS_PER_SEC
);
*
fsec
-=
(
sec
*
USECS_PER_SEC
);
#else
TMODULO
(
*
fsec
,
sec
,
1e0
);
#endif
...
...
@@ -702,14 +702,14 @@ interval2tm(interval span, struct tm * tm, fsec_t *fsec)
#ifdef HAVE_INT64_TIMESTAMP
tm
->
tm_mday
=
(
time
/
USECS_PER_DAY
);
time
-=
(
tm
->
tm_mday
*
USECS_PER_DAY
);
tm
->
tm_hour
=
(
time
/
INT64CONST
(
3600000000
)
);
time
-=
(
tm
->
tm_hour
*
INT64CONST
(
3600000000
)
);
tm
->
tm_min
=
(
time
/
INT64CONST
(
60000000
)
);
time
-=
(
tm
->
tm_min
*
INT64CONST
(
60000000
)
);
tm
->
tm_sec
=
(
time
/
INT64CONST
(
1000000
)
);
*
fsec
=
(
time
-
(
tm
->
tm_sec
*
INT64CONST
(
1000000
)
));
tm
->
tm_hour
=
(
time
/
USECS_PER_HOUR
);
time
-=
(
tm
->
tm_hour
*
USECS_PER_HOUR
);
tm
->
tm_min
=
(
time
/
USECS_PER_MINUTE
);
time
-=
(
tm
->
tm_min
*
USECS_PER_MINUTE
);
tm
->
tm_sec
=
(
time
/
USECS_PER_SEC
);
*
fsec
=
(
time
-
(
tm
->
tm_sec
*
USECS_PER_SEC
));
#else
TMODULO
(
time
,
tm
->
tm_mday
,
86400e0
);
TMODULO
(
time
,
tm
->
tm_mday
,
(
double
)
SECS_PER_DAY
);
TMODULO
(
time
,
tm
->
tm_hour
,
3600e0
);
TMODULO
(
time
,
tm
->
tm_min
,
60e0
);
TMODULO
(
time
,
tm
->
tm_sec
,
1e0
);
...
...
@@ -727,7 +727,7 @@ tm2interval(struct tm * tm, fsec_t fsec, interval *span)
span
->
time
=
((((((((
tm
->
tm_mday
*
INT64CONST
(
24
))
+
tm
->
tm_hour
)
*
INT64CONST
(
60
))
+
tm
->
tm_min
)
*
INT64CONST
(
60
))
+
tm
->
tm_sec
)
*
INT64CONST
(
1000000
)
)
+
fsec
);
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
);
#else
span
->
time
=
((((((
tm
->
tm_mday
*
24
.
0
)
+
tm
->
tm_hour
)
*
60
.
0
)
...
...
src/interfaces/ecpg/pgtypeslib/timestamp.c
View file @
4550c1e5
...
...
@@ -20,7 +20,7 @@ int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int
static
int64
time2t
(
const
int
hour
,
const
int
min
,
const
int
sec
,
const
fsec_t
fsec
)
{
return
((((((
hour
*
60
)
+
min
)
*
60
)
+
sec
)
*
INT64CONST
(
1000000
)
)
+
fsec
);
return
((((((
hour
*
60
)
+
min
)
*
60
)
+
sec
)
*
USECS_PER_SEC
)
+
fsec
);
}
/* time2t() */
#else
...
...
@@ -35,7 +35,7 @@ static timestamp
dt2local
(
timestamp
dt
,
int
tz
)
{
#ifdef HAVE_INT64_TIMESTAMP
dt
-=
(
tz
*
INT64CONST
(
1000000
)
);
dt
-=
(
tz
*
USECS_PER_SEC
);
#else
dt
-=
tz
;
dt
=
JROUND
(
dt
);
...
...
@@ -77,7 +77,7 @@ tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp *result)
if
((
*
result
<
0
)
?
(
dDate
>=
0
)
:
(
dDate
<
0
))
return
-
1
;
#else
*
result
=
((
dDate
*
86400
)
+
time
);
*
result
=
((
dDate
*
SECS_PER_DAY
)
+
time
);
#endif
if
(
tzp
!=
NULL
)
*
result
=
dt2local
(
*
result
,
-
(
*
tzp
));
...
...
@@ -110,14 +110,14 @@ dt2time(timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
time
=
jd
;
#ifdef HAVE_INT64_TIMESTAMP
*
hour
=
(
time
/
INT64CONST
(
3600000000
)
);
time
-=
((
*
hour
)
*
INT64CONST
(
3600000000
)
);
*
min
=
(
time
/
INT64CONST
(
60000000
)
);
time
-=
((
*
min
)
*
INT64CONST
(
60000000
)
);
*
sec
=
(
time
/
INT64CONST
(
1000000
)
);
*
fsec
=
(
time
-
(
*
sec
*
INT64CONST
(
1000000
)
));
*
sec
=
(
time
/
INT64CONST
(
1000000
)
);
*
fsec
=
(
time
-
(
*
sec
*
INT64CONST
(
1000000
)
));
*
hour
=
(
time
/
USECS_PER_HOUR
);
time
-=
((
*
hour
)
*
USECS_PER_HOUR
);
*
min
=
(
time
/
USECS_PER_MINUTE
);
time
-=
((
*
min
)
*
USECS_PER_MINUTE
);
*
sec
=
(
time
/
USECS_PER_SEC
);
*
fsec
=
(
time
-
(
*
sec
*
USECS_PER_SEC
));
*
sec
=
(
time
/
USECS_PER_SEC
);
*
fsec
=
(
time
-
(
*
sec
*
USECS_PER_SEC
));
#else
*
hour
=
(
time
/
3600
);
time
-=
((
*
hour
)
*
3600
);
...
...
@@ -171,11 +171,11 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
dDate
-=
1
;
}
#else
TMODULO
(
time
,
dDate
,
86400e0
);
TMODULO
(
time
,
dDate
,
(
double
)
SECS_PER_DAY
);
if
(
time
<
0
)
{
time
+=
86400
;
time
+=
SECS_PER_DAY
;
dDate
-=
1
;
}
#endif
...
...
@@ -199,10 +199,10 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
if
(
IS_VALID_UTIME
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
))
{
#ifdef HAVE_INT64_TIMESTAMP
utime
=
((
dt
/
INT64CONST
(
1000000
)
)
+
((
date0
-
date2j
(
1970
,
1
,
1
))
*
INT64CONST
(
86400
)));
utime
=
((
dt
/
USECS_PER_SEC
)
+
((
date0
-
date2j
(
1970
,
1
,
1
))
*
INT64CONST
(
SECS_PER_DAY
)));
#else
utime
=
(
dt
+
((
date0
-
date2j
(
1970
,
1
,
1
))
*
86400
));
utime
=
(
dt
+
((
date0
-
date2j
(
1970
,
1
,
1
))
*
SECS_PER_DAY
));
#endif
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
...
...
src/timezone/pgtz.c
View file @
4550c1e5
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.3
0 2005/04/19 03:13:59
momjian Exp $
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.3
1 2005/05/23 21:54:02
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1062,7 +1062,7 @@ tz_acceptable(pg_tz *tz)
* be GMT midnight, 2000-01-01. Insist that the tm_sec value be zero;
* any other result has to be due to leap seconds.
*/
time2000
=
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
86400
;
time2000
=
(
POSTGRES_EPOCH_JDATE
-
UNIX_EPOCH_JDATE
)
*
SECS_PER_DAY
;
tt
=
pg_localtime
(
&
time2000
,
tz
);
if
(
!
tt
||
tt
->
tm_sec
!=
0
)
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment