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
ada3ad75
Commit
ada3ad75
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Added function secofday_encode() and secofday_decode().
parent
3846ba47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#18345
failed
1 month ago
Stage: external
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/julian_date.c
+41
-0
41 additions, 0 deletions
src/julian_date.c
src/julian_date.h
+4
-0
4 additions, 0 deletions
src/julian_date.h
with
45 additions
and
0 deletions
src/julian_date.c
+
41
−
0
View file @
ada3ad75
#include
"julian_date.h"
#include
<math.h>
double
secofday_encode
(
CdiTime
time
)
{
const
int
hour
=
time
.
hour
;
const
int
minute
=
time
.
minute
;
const
int
second
=
time
.
second
;
return
hour
*
3600
+
minute
*
60
+
second
+
time
.
ms
/
1000
.
0
;
}
CdiTime
secofday_decode
(
double
secondOfDay
)
{
CdiTime
time
;
const
int
fullSeconds
=
(
int
)
secondOfDay
;
time
.
ms
=
(
int
)
lround
((
secondOfDay
-
fullSeconds
)
*
1000
);
const
int
hour
=
fullSeconds
/
3600
;
const
int
minute
=
fullSeconds
/
60
-
hour
*
60
;
const
int
second
=
fullSeconds
-
hour
*
3600
-
minute
*
60
;
time
.
hour
=
hour
;
time
.
minute
=
minute
;
time
.
second
=
second
;
return
time
;
}
JulianDate
julianDate_encode
(
int
calendar
,
CdiDateTime
dt
)
...
...
@@ -10,7 +40,18 @@ julianDate_encode(int calendar, CdiDateTime dt)
return
julianDate
;
}
/*
CdiDateTime
julianDate_decode(int calendar, JulianDate julianDate)
{
CdiDateTime dt;
decode_calday(calendar, julianDate.julianDay, &dt.date.year, &dt.date.month, &dt.date.day);
decode_secofday(julianDate.secondOfDay, &dt.time.hour, &dt.time.minute, &dt.time.second, &dt.time.ms);
return dt;
}
*/
static
void
adjust_seconds
(
JulianDate
*
julianDate
)
{
...
...
This diff is collapsed.
Click to expand it.
src/julian_date.h
+
4
−
0
View file @
ada3ad75
...
...
@@ -17,9 +17,13 @@ typedef struct
}
JulianDate
;
JulianDate
julianDate_encode
(
int
calendar
,
CdiDateTime
dt
);
CdiDateTime
julianDate_decode
(
int
calendar
,
JulianDate
julianDate
);
JulianDate
julianDate_add
(
JulianDate
julianDate1
,
JulianDate
julianDate2
);
JulianDate
julianDate_sub
(
JulianDate
julianDate1
,
JulianDate
julianDate2
);
double
secofday_encode
(
CdiTime
time
);
CdiTime
secofday_decode
(
double
secondOfDay
);
#ifdef __cplusplus
}
#endif
...
...
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