Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
d7754f9e
Commit
d7754f9e
authored
Oct 01, 2007
by
Uwe Schulzweida
Browse files
timebase:encode_julday bug fix for years < 0
parent
fad976e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/timebase.c
View file @
d7754f9e
...
...
@@ -79,28 +79,33 @@ void decode_julday(
/* convert year, month, day into Julian calendar day */
int
encode_julday
(
int
year
,
int
month
,
int
day
)
{
int
y
;
int
m
;
int
i
y
;
int
i
m
;
int
ib
;
int
julday
;
if
(
month
<=
2
)
{
y
=
year
-
1
;
m
=
month
+
12
;
i
y
=
year
-
1
;
i
m
=
month
+
12
;
}
else
{
y
=
year
;
m
=
month
;
i
y
=
year
;
i
m
=
month
;
}
if
(
iy
<
0
)
ib
=
(
int
)((
iy
+
1
)
/
400
)
-
(
int
)((
iy
+
1
)
/
100
);
else
ib
=
(
int
)(
iy
/
400
)
-
(
int
)(
iy
/
100
);
if
(
year
>
1582
||
(
year
==
1582
&&
(
month
>
10
||
(
month
==
10
&&
day
>=
15
)))
)
{
/*
** 15th October 1582 AD or later
*/
ib
=
(
int
)(
y
/
400
)
-
(
int
)(
y
/
100
);
}
else
{
...
...
@@ -110,7 +115,7 @@ int encode_julday(int year, int month, int day)
ib
=
-
2
;
}
julday
=
(
int
)
(
floor
(
365
.
25
*
y
)
+
(
int
)(
30
.
6001
*
(
m
+
1
))
+
ib
+
1720996
.
5
+
day
+
0
.
5
);
julday
=
(
int
)
(
floor
(
365
.
25
*
i
y
)
+
(
int
)(
30
.
6001
*
(
i
m
+
1
))
+
ib
+
1720996
.
5
+
day
+
0
.
5
);
return
(
julday
);
}
...
...
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