Skip to content

Commit

Permalink
hygiene, simplify cases in __to_unix_epoch() of dt-core.c
Browse files Browse the repository at this point in the history
  • Loading branch information
hroptatyr committed May 31, 2018
1 parent 7b696fc commit 48d68e7
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/dt-core.c
Expand Up @@ -126,24 +126,22 @@ static inline dt_ssexy_t
__to_unix_epoch(struct dt_dt_s dt)
{
/* daisy is competing with the prevalent unix epoch, this is the offset */
struct dt_d_s dd;
dt_ssexy_t res;

if (dt.typ == DT_SEXY) {
/* no way to find out, is there */
return dt.sexy;
} else if (dt_sandwich_p(dt) || dt_sandwich_only_d_p(dt)) {
dt_daisy_t d = dt_conv_to_daisy(dt.d);
dt_ssexy_t res = (d - DAISY_UNIX_BASE) * SECS_PER_DAY;
if (dt_sandwich_p(dt)) {
res += (dt.t.hms.h * 60 + dt.t.hms.m) * 60 + dt.t.hms.s;
}
return res;
dd = dt.d;
} else if (dt_sandwich_only_t_p(dt)) {
/* bug/65, fill in with base */
dt_daisy_t d = dt_conv_to_daisy(dt_get_base().d);
dt_ssexy_t res = (d - DAISY_UNIX_BASE) * SECS_PER_DAY;
res += (dt.t.hms.h * 60 + dt.t.hms.m) * 60 + dt.t.hms.s;
return res;
dd = dt_get_base().d;
} else {
return 0;
}
return 0;
res = (dt_conv_to_daisy(dd) - DAISY_UNIX_BASE) * SECS_PER_DAY;
res += (dt.t.hms.h * 60 + dt.t.hms.m) * 60 + dt.t.hms.s;
return res;
}

/* public version */
Expand Down

0 comments on commit 48d68e7

Please sign in to comment.