Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
fd334d7f
Commit
fd334d7f
authored
Aug 04, 2017
by
Uwe Schulzweida
Browse files
Added CALENDAR_GREGORIAN.
parent
e32d5b87
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/calendar.c
View file @
fd334d7f
...
...
@@ -58,7 +58,7 @@ int days_per_year(int calendar, int year)
if
(
daysperyear
==
0
)
{
if
(
year
==
1582
&&
calendar
==
CALENDAR_STANDARD
)
if
(
year
==
1582
&&
(
calendar
==
CALENDAR_STANDARD
||
calendar
==
CALENDAR_GREGORIAN
)
)
daysperyear
=
355
;
else
if
(
(
year
%
4
==
0
&&
year
%
100
!=
0
)
||
year
%
400
==
0
)
daysperyear
=
366
;
...
...
src/cdf_util.c
View file @
fd334d7f
...
...
@@ -316,9 +316,10 @@ void set_zaxistype(const char *attstring, int *zaxistype)
void
set_calendar
(
const
char
*
attstring
,
int
*
calendar
)
{
if
(
str_is_equal
(
attstring
,
"standard"
)
||
str_is_equal
(
attstring
,
"gregorian"
)
)
if
(
str_is_equal
(
attstring
,
"standard"
)
)
*
calendar
=
CALENDAR_STANDARD
;
else
if
(
str_is_equal
(
attstring
,
"gregorian"
)
)
*
calendar
=
CALENDAR_GREGORIAN
;
else
if
(
str_is_equal
(
attstring
,
"none"
)
)
*
calendar
=
CALENDAR_NONE
;
else
if
(
str_is_equal
(
attstring
,
"proleptic"
)
)
...
...
src/cdi.h
View file @
fd334d7f
...
...
@@ -267,11 +267,12 @@ typedef struct {
/* CALENDAR types */
#define CALENDAR_STANDARD 0
/* don't change this value (used also in cgribexlib)! */
#define CALENDAR_PROLEPTIC 1
#define CALENDAR_360DAYS 2
#define CALENDAR_365DAYS 3
#define CALENDAR_366DAYS 4
#define CALENDAR_NONE 5
#define CALENDAR_GREGORIAN 1
#define CALENDAR_PROLEPTIC 2
#define CALENDAR_360DAYS 3
#define CALENDAR_365DAYS 4
#define CALENDAR_366DAYS 5
#define CALENDAR_NONE 6
/* number of unsigned char needed to store UUID */
#define CDI_UUID_SIZE 16
...
...
src/cdi_int.c
View file @
fd334d7f
...
...
@@ -425,6 +425,8 @@ void cdiInitialize(void)
{
if
(
strncmp
(
envstr
,
"standard"
,
8
)
==
0
)
cdiDefaultCalendar
=
CALENDAR_STANDARD
;
else
if
(
strncmp
(
envstr
,
"gregorian"
,
9
)
==
0
)
cdiDefaultCalendar
=
CALENDAR_GREGORIAN
;
else
if
(
strncmp
(
envstr
,
"proleptic"
,
9
)
==
0
)
cdiDefaultCalendar
=
CALENDAR_PROLEPTIC
;
else
if
(
strncmp
(
envstr
,
"360days"
,
7
)
==
0
)
...
...
src/stream_cdf_time.c
View file @
fd334d7f
...
...
@@ -4,15 +4,15 @@
#ifdef HAVE_LIBNETCDF
#
include <stdio.h>
#
include <string.h>
#include
<stdio.h>
#include
<string.h>
#
include <netcdf.h>
#include
<netcdf.h>
#
include "cdi.h"
#
include "cdi_int.h"
#
include "stream_cdf.h"
#
include "cdf_int.h"
#include
"cdi.h"
#include
"cdi_int.h"
#include
"stream_cdf.h"
#include
"cdf_int.h"
static
int
cdfDefTimeBounds
(
int
fileID
,
int
nctimevarid
,
int
nctimedimid
,
const
char
*
taxis_name
,
taxis_t
*
taxis
)
...
...
@@ -119,6 +119,7 @@ void cdfDefCalendar(int fileID, int ncvarid, int calendar)
{
static
const
struct
{
int
calCode
;
const
char
*
calStr
;
}
calTab
[]
=
{
{
CALENDAR_STANDARD
,
"standard"
},
{
CALENDAR_GREGORIAN
,
"gregorian"
},
{
CALENDAR_PROLEPTIC
,
"proleptic_gregorian"
},
{
CALENDAR_NONE
,
"none"
},
{
CALENDAR_360DAYS
,
"360_day"
},
...
...
src/timebase.c
View file @
fd334d7f
...
...
@@ -17,7 +17,7 @@ void decode_julday(int calendar,
double
b
=
floor
((
a
-
1867216
.
25
)
/
36524
.
25
);
double
c
=
a
+
b
-
floor
(
b
/
4
)
+
1525
;
if
(
calendar
==
CALENDAR_STANDARD
)
if
(
calendar
==
CALENDAR_STANDARD
||
calendar
==
CALENDAR_GREGORIAN
)
if
(
a
<
2299161
)
c
=
a
+
1524
;
double
d
=
floor
((
c
-
122
.
1
)
/
365
.
25
);
...
...
@@ -54,7 +54,7 @@ int encode_julday(int calendar, int year, int month, int day)
else
ib
=
(
int
)(
iy
/
400
)
-
(
int
)(
iy
/
100
);
if
(
calendar
==
CALENDAR_STANDARD
)
if
(
calendar
==
CALENDAR_STANDARD
||
calendar
==
CALENDAR_GREGORIAN
)
{
if
(
year
>
1582
||
(
year
==
1582
&&
(
month
>
10
||
(
month
==
10
&&
day
>=
15
)))
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment