Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
83adddfc
Commit
83adddfc
authored
28 years ago
by
Marc G. Fournier
Browse files
Options
Downloads
Patches
Plain Diff
- improve date/time parsing routines
- submitted by: Massimo Dal Zotto <dz@cs.unitn.it>
parent
a7cfd655
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/utils/adt/datetimes.c
+32
-9
32 additions, 9 deletions
src/backend/utils/adt/datetimes.c
with
32 additions
and
9 deletions
src/backend/utils/adt/datetimes.c
+
32
−
9
View file @
83adddfc
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.
1.1.1
1996/07/
0
9 0
6:22:03
scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/datetimes.c,v 1.
2
1996/07/
1
9 0
7:19:56
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -57,11 +57,15 @@ date_in(char *datestr)
...
@@ -57,11 +57,15 @@ date_in(char *datestr)
int4
result
;
int4
result
;
DateADT
*
date
=
(
DateADT
*
)
&
result
;
DateADT
*
date
=
(
DateADT
*
)
&
result
;
#if 0
#ifdef USE_SHORT_YEAR
#ifdef USE_SHORT_YEAR
#define CHECK_DATE_LEN(datestr) (strlen(datestr) >= 8)
#define CHECK_DATE_LEN(datestr) (strlen(datestr) >= 8)
#else
#else
#define CHECK_DATE_LEN(datestr) (strlen(datestr) == 10)
#define CHECK_DATE_LEN(datestr) (strlen(datestr) == 10)
#endif /* USE_SHORT_YEAR */
#endif /* USE_SHORT_YEAR */
#else
#define CHECK_DATE_LEN(datestr) 1
#endif
#ifdef AMERICAN_STYLE
#ifdef AMERICAN_STYLE
if
(
!
CHECK_DATE_LEN
(
datestr
)
||
if
(
!
CHECK_DATE_LEN
(
datestr
)
||
...
@@ -76,6 +80,8 @@ date_in(char *datestr)
...
@@ -76,6 +80,8 @@ date_in(char *datestr)
datestr
);
datestr
);
}
}
#endif
#endif
if
(
y
<
0
||
y
>
32767
)
elog
(
WARN
,
"date_in: year must be limited to values 0 through 32767 in
\"
%s
\"
"
,
datestr
);
if
(
m
<
1
||
m
>
12
)
if
(
m
<
1
||
m
>
12
)
elog
(
WARN
,
"date_in: month must be limited to values 1 through 12 in
\"
%s
\"
"
,
datestr
);
elog
(
WARN
,
"date_in: month must be limited to values 1 through 12 in
\"
%s
\"
"
,
datestr
);
if
(
d
<
1
||
d
>
day_tab
[
isleap
(
y
)][
m
-
1
])
if
(
d
<
1
||
d
>
day_tab
[
isleap
(
y
)][
m
-
1
])
...
@@ -247,16 +253,19 @@ time_in(char *timestr)
...
@@ -247,16 +253,19 @@ time_in(char *timestr)
TimeADT
*
time
;
TimeADT
*
time
;
if
(
sscanf
(
timestr
,
"%d%*c%d%*c%f"
,
&
h
,
&
m
,
&
sec
)
!=
3
)
{
if
(
sscanf
(
timestr
,
"%d%*c%d%*c%f"
,
&
h
,
&
m
,
&
sec
)
!=
3
)
{
sec
=
0
.
0
;
if
(
sscanf
(
timestr
,
"%d%*c%d"
,
&
h
,
&
m
)
!=
2
)
{
elog
(
WARN
,
"time_in: time
\"
%s
\"
not of the form hh:mm:ss"
,
elog
(
WARN
,
"time_in: time
\"
%s
\"
not of the form hh:mm:ss"
,
timestr
);
timestr
);
}
}
}
if
(
h
<
0
||
h
>
23
)
if
(
h
<
0
||
h
>
23
)
elog
(
WARN
,
"time_in: hour must be limited to values 0 through 23 in
\"
%s
\"
"
,
timestr
);
elog
(
WARN
,
"time_in: hour must be limited to values 0 through 23 in
\"
%s
\"
"
,
timestr
);
if
(
m
<
0
||
m
>
59
)
if
(
m
<
0
||
m
>
59
)
elog
(
WARN
,
"time_in: minute must be limited to values 0 through 59 in
\"
%s
\"
"
,
timestr
);
elog
(
WARN
,
"time_in: minute must be limited to values 0 through 59 in
\"
%s
\"
"
,
timestr
);
if
(
sec
<
0
||
sec
>=
6
2
.
0
)
if
(
sec
<
0
||
sec
>=
6
0
.
0
)
elog
(
WARN
,
"time_in: second must be limited to values 0 through
61.
99 in
\"
%s
\"
"
,
timestr
);
elog
(
WARN
,
"time_in: second must be limited to values 0 through
59.9
99 in
\"
%s
\"
"
,
timestr
);
time
=
(
TimeADT
*
)
palloc
(
sizeof
(
TimeADT
));
time
=
(
TimeADT
*
)
palloc
(
sizeof
(
TimeADT
));
time
->
hr
=
h
;
time
->
hr
=
h
;
...
@@ -268,10 +277,24 @@ time_in(char *timestr)
...
@@ -268,10 +277,24 @@ time_in(char *timestr)
char
*
char
*
time_out
(
TimeADT
*
time
)
time_out
(
TimeADT
*
time
)
{
{
char
*
timestr
=
palloc
(
16
);
char
*
timestr
=
palloc
(
32
);
int
n
;
float
f
;
if
(
time
->
sec
==
0
.
0
)
{
sprintf
(
timestr
,
"%02d:%02d"
,
(
int
)
time
->
hr
,
(
int
)
time
->
min
);
}
else
{
n
=
(
int
)
time
->
sec
;
f
=
(
float
)
n
;
if
(
f
==
time
->
sec
)
{
sprintf
(
timestr
,
"%02d:%02d:%02d"
,
(
int
)
time
->
hr
,
(
int
)
time
->
min
,
n
);
}
else
{
sprintf
(
timestr
,
"%02d:%02d:%09.6f"
,
sprintf
(
timestr
,
"%02d:%02d:%09.6f"
,
(
int
)
time
->
hr
,
(
int
)
time
->
min
,
time
->
sec
);
(
int
)
time
->
hr
,
(
int
)
time
->
min
,
time
->
sec
);
}
}
return
timestr
;
return
timestr
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment