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
3ce0236c
Commit
3ce0236c
authored
Mar 02, 1997
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply date patch from tiemann@cygnus.com,Michael Tiemann.
parent
162c2a6e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
16 deletions
+38
-16
src/backend/utils/adt/datetimes.c
src/backend/utils/adt/datetimes.c
+38
-16
No files found.
src/backend/utils/adt/datetimes.c
View file @
3ce0236c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.
8 1997/01/26 15:31:12 scrappy
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.
9 1997/03/02 02:05:33 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -240,19 +240,26 @@ date_smaller(int4 dateVal1, int4 dateVal2)
...
@@ -240,19 +240,26 @@ date_smaller(int4 dateVal1, int4 dateVal2)
int32
int32
date_mi
(
int4
dateVal1
,
int4
dateVal2
)
date_mi
(
int4
dateVal1
,
int4
dateVal2
)
{
{
int4
dv1
,
dv2
;
DateADT
*
date1
,
*
date2
;
DateADT
*
date1
,
*
date2
;
int32
days
=
0
;
int32
days
=
0
;
int
i
;
int
i
;
date1
=
(
DateADT
*
)
&
dateVal1
;
/* This circumlocution allows us to assume that date1 is always
date2
=
(
DateADT
*
)
&
dateVal2
;
before date2. */
dv1
=
date_smaller
(
dateVal1
,
dateVal2
);
dv2
=
date_larger
(
dateVal1
,
dateVal2
);
date1
=
(
DateADT
*
)
&
dv1
;
date2
=
(
DateADT
*
)
&
dv2
;
/* Sum number of days in each full year between date1 and date2. */
/* Sum number of days in each full year between date1 and date2. */
for
(
i
=
date1
->
year
+
1
;
i
<
date2
->
year
;
++
i
)
for
(
i
=
date1
->
year
+
1
;
i
<
date2
->
year
;
++
i
)
days
+=
isleap
(
i
)
?
366
:
365
;
days
+=
isleap
(
i
)
?
366
:
365
;
/* Add in number of days in each full month from date1 to end of
if
(
days
)
year. */
{
/* We need to wrap around the year. Add in number of days in each
full month from date1 to end of year. */
for
(
i
=
date1
->
month
+
1
;
i
<=
12
;
++
i
)
for
(
i
=
date1
->
month
+
1
;
i
<=
12
;
++
i
)
days
+=
day_tab
[
isleap
(
date1
->
year
)][
i
-
1
];
days
+=
day_tab
[
isleap
(
date1
->
year
)][
i
-
1
];
...
@@ -260,12 +267,27 @@ date_mi(int4 dateVal1, int4 dateVal2)
...
@@ -260,12 +267,27 @@ date_mi(int4 dateVal1, int4 dateVal2)
date2. */
date2. */
for
(
i
=
1
;
i
<
date2
->
month
;
++
i
)
for
(
i
=
1
;
i
<
date2
->
month
;
++
i
)
days
+=
day_tab
[
isleap
(
date2
->
year
)][
i
-
1
];
days
+=
day_tab
[
isleap
(
date2
->
year
)][
i
-
1
];
}
else
{
/* Add in number of days in each full month from date1 to date2. */
for
(
i
=
date1
->
month
+
1
;
i
<
date2
->
month
;
++
i
)
days
+=
day_tab
[
isleap
(
date1
->
year
)][
i
-
1
];
}
if
(
days
||
date1
->
month
!=
date2
->
month
)
{
/* Add in number of days left in month for date1. */
/* Add in number of days left in month for date1. */
days
+=
day_tab
[
isleap
(
date1
->
year
)][
date1
->
month
-
1
]
-
date1
->
day
;
days
+=
day_tab
[
isleap
(
date1
->
year
)][
date1
->
month
-
1
]
-
date1
->
day
;
/* Add in day of month of date2. */
/* Add in day of month of date2. */
days
+=
date2
->
day
;
days
+=
date2
->
day
;
}
else
{
/* Everything's in the same month, so just subtract the days! */
days
=
date2
->
day
-
date1
->
day
;
}
return
(
days
);
return
(
days
);
}
}
...
...
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