Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
mpim-sw
libcdi
Commits
9e5d70fa
Commit
9e5d70fa
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Added function calDay_decode() and calDay_encode().
parent
ada3ad75
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#18349
failed
1 month ago
Stage: external
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/calendar.c
+30
-1
30 additions, 1 deletion
src/calendar.c
src/calendar.h
+4
-1
4 additions, 1 deletion
src/calendar.h
src/julian_date.c
+6
-6
6 additions, 6 deletions
src/julian_date.c
with
40 additions
and
8 deletions
src/calendar.c
+
30
−
1
View file @
9e5d70fa
#include
<limits.h>
#include
<stdio.h>
#include
"cdi.h"
/* CALENDAR_ */
#include
"calendar.h"
#include
"error.h"
#include
"timebase.h"
...
...
@@ -122,6 +121,36 @@ decode_calday(int calendar, int64_t julday, int *year, int *month, int *day)
decode_julday
(
calendar
,
julday
,
year
,
month
,
day
);
}
int64_t
calDay_encode
(
int
calendar
,
CdiDate
date
)
{
const
int
dpy
=
calendar_dpy
(
calendar
);
if
(
dpy
==
360
||
dpy
==
365
||
dpy
==
366
)
return
encode_day
(
dpy
,
date
.
year
,
date
.
month
,
date
.
day
);
else
return
encode_julday
(
calendar
,
date
.
year
,
date
.
month
,
date
.
day
);
}
CdiDate
calDay_decode
(
int
calendar
,
int64_t
julday
)
{
int
year
,
month
,
day
;
const
int
dpy
=
calendar_dpy
(
calendar
);
if
(
dpy
==
360
||
dpy
==
365
||
dpy
==
366
)
decode_day
(
dpy
,
julday
,
&
year
,
&
month
,
&
day
);
else
decode_julday
(
calendar
,
julday
,
&
year
,
&
month
,
&
day
);
CdiDate
date
;
date
.
year
=
year
;
date
.
month
=
month
;
date
.
day
=
day
;
return
date
;
}
#ifdef TEST
static
int
date_to_calday
(
int
calendar
,
int64_t
date
)
...
...
This diff is collapsed.
Click to expand it.
src/calendar.h
+
4
−
1
View file @
9e5d70fa
...
...
@@ -3,7 +3,7 @@
// clang-format off
#include
<inttypes
.h
>
#include
"cdi
.h
"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -12,6 +12,9 @@ extern "C" {
int64_t
encode_calday
(
int
calendar
,
int
year
,
int
month
,
int
day
);
void
decode_calday
(
int
calendar
,
int64_t
julday
,
int
*
year
,
int
*
month
,
int
*
day
);
int64_t
calDay_encode
(
int
calendar
,
CdiDate
date
);
CdiDate
calDay_decode
(
int
calendar
,
int64_t
julday
);
int
calendar_dpy
(
int
calendar
);
int
days_per_year
(
int
calendar
,
int
year
);
int
days_per_month
(
int
calendar
,
int
year
,
int
month
);
...
...
This diff is collapsed.
Click to expand it.
src/julian_date.c
+
6
−
6
View file @
9e5d70fa
...
...
@@ -35,23 +35,23 @@ julianDate_encode(int calendar, CdiDateTime dt)
{
JulianDate
julianDate
;
julianDate
.
julianDay
=
encode_calday
(
calendar
,
dt
.
date
.
year
,
dt
.
date
.
month
,
dt
.
date
.
day
);
julianDate
.
secondOfDay
=
encode_
secofday
(
dt
.
time
.
hour
,
dt
.
time
.
minute
,
dt
.
time
.
second
,
dt
.
time
.
ms
);
julianDate
.
julianDay
=
calDay_encode
(
calendar
,
dt
.
date
);
julianDate
.
secondOfDay
=
secofday
_encode
(
dt
.
time
);
return
julianDate
;
}
/*
CdiDateTime
julianDate_decode
(
int
calendar
,
JulianDate
julianDate
)
{
CdiDateTime
dt
;
d
ecode_
cal
d
ay(calendar, julianDate.julianDay
, &dt.date.year, &dt.date.month, &dt.date.day
);
d
ecode_secofday(julianDate.secondOfDay, &dt.time.hour, &dt.time.minute, &dt.time.second, &dt.time.ms
);
d
t
.
date
=
cal
D
ay
_decode
(
calendar
,
julianDate
.
julianDay
);
d
t
.
time
=
secofday_decode
(
julianDate
.
secondOfDay
);
return
dt
;
}
*/
static
void
adjust_seconds
(
JulianDate
*
julianDate
)
{
...
...
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