Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmtime
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
icon-libraries
libmtime
Commits
8bc64b9f
Commit
8bc64b9f
authored
4 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Straighten control flow in localTimeDeltaToJulianDelta_NonStandardTimeDelta.
parent
a098a907
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Intentional change
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mtime_timedelta.c
+24
-46
24 additions, 46 deletions
src/mtime_timedelta.c
with
24 additions
and
46 deletions
src/mtime_timedelta.c
+
24
−
46
View file @
8bc64b9f
...
...
@@ -467,59 +467,37 @@ else
static
struct
_juliandelta
*
localTimeDeltaToJulianDelta_NonStandardTimeDelta
(
struct
_timedelta
*
td
,
struct
_datetime
*
base_dt
,
struct
_juliandelta
*
jd_return
)
{
if
(
td
->
sign
==
'-'
)
{
/* Negative TimeDelta. A negative juliandelta is represented in the following
way: -P01DT00.500S = jd2->sign = '-', jd2->day = -30, jd2->ms = -500. */
jd_return
->
sign
=
'-'
;
/* Non standard Months not supported. */
/* Day. */
jd_return
->
day
=
(
-
1
)
*
(
int64_t
)
td
->
day
;
/* Rest. */
jd_return
->
ms
=
(
-
1
)
*
(
int64_t
)
td
->
hour
*
NO_OF_MS_IN_A_HOUR
+
(
-
1
)
*
(
int64_t
)
td
->
minute
*
NO_OF_MS_IN_A_MINUTE
+
(
-
1
)
*
(
int64_t
)
td
->
second
*
NO_OF_MS_IN_A_SECOND
+
(
-
1
)
*
td
->
ms
;
/* No need to promote ms to int64_t; ms greater than 999 not supported even in non std long form. */
while
(
jd_return
->
ms
<=
(
-
1
)
*
NO_OF_MS_IN_A_DAY
)
{
jd_return
->
ms
=
jd_return
->
ms
+
NO_OF_MS_IN_A_DAY
;
jd_return
->
day
--
;
}
{
int64_t
sign_apply
=
td
->
sign
==
'-'
?
-
1
:
(
td
->
sign
==
'+'
?
1
:
0
);
if
(
sign_apply
)
{
/* Positive or negative timedelta can be handled symmetrically. */
/* Negative TimeDelta. A negative juliandelta is represented in the following
way: -P01DT00.500S = jd2->sign = '-', jd2->day = -30, jd2->ms = -500. */
}
else
if
(
td
->
sign
==
'+'
)
{
/* Positive TimeDelta. */
jd_return
->
sign
=
sign_apply
<
0
?
'-'
:
'+'
;
jd_return
->
sign
=
'+'
;
/* Non standard Months not supported. */
/* Non standard Months not supported. */
/* Day. */
int64_t
day
=
sign_apply
*
(
int64_t
)
td
->
day
;
/* Rest. */
int64_t
ms
=
sign_apply
*
(
int64_t
)
td
->
hour
*
NO_OF_MS_IN_A_HOUR
+
sign_apply
*
(
int64_t
)
td
->
minute
*
NO_OF_MS_IN_A_MINUTE
+
sign_apply
*
(
int64_t
)
td
->
second
*
NO_OF_MS_IN_A_SECOND
+
sign_apply
*
td
->
ms
;
/* No need to promote ms to int64_t; ms greater than 999 not supported even in non std long form. */
/* Day. */
jd_return
->
day
=
(
int64_t
)
td
->
day
;
/* Rest. */
jd_return
->
ms
=
(
int64_t
)
td
->
hour
*
NO_OF_MS_IN_A_HOUR
+
(
int64_t
)
td
->
minute
*
NO_OF_MS_IN_A_MINUTE
+
(
int64_t
)
td
->
second
*
NO_OF_MS_IN_A_SECOND
+
td
->
ms
;
/* No need to promote ms to int64_t; ms greater than 999 not supported even in non std long form. */
day
+=
ms
/
NO_OF_MS_IN_A_DAY
;
ms
=
ms
%
NO_OF_MS_IN_A_DAY
;
while
(
jd_return
->
ms
>=
NO_OF_MS_IN_A_DAY
)
{
jd_return
->
ms
=
jd_return
->
ms
-
NO_OF_MS_IN_A_DAY
;
jd_return
->
day
++
;
}
}
else
return
NULL
;
/* ERROR: TD sign not defined. Should never happen. */
jd_return
->
day
=
day
;
jd_return
->
ms
=
ms
;
return
jd_return
;
}
else
return
NULL
;
/* ERROR: TD sign not defined. Should never happen. */
return
jd_return
;
}
static
...
...
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