Skip to content

Commit

Permalink
Fix PR#18401. By Hannes Mühleisen.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@82892 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Sep 21, 2022
1 parent 17e4b35 commit 4f70ce0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static double mktime00 (stm *tm)
}

/* weekday: Epoch day was a Thursday */
if ((tm->tm_wday = (day + 4) % 7) < 0) tm->tm_wday += 7;
if ((tm->tm_wday = ((day % 7) + 4) % 7) < 0) tm->tm_wday += 7;

return tm->tm_sec + (tm->tm_min * 60) + (tm->tm_hour * 3600)
+ (day + excess * 730485) * 86400.0;
Expand Down Expand Up @@ -474,7 +474,7 @@ static stm * localtime0(const double *tp, const int local, stm *ltm)
res->tm_sec = left % 60;

/* weekday: 1970-01-01 was a Thursday */
if ((res->tm_wday = ((4 + day) % 7)) < 0) res->tm_wday += 7;
if ((res->tm_wday = (((day % 7) + 4) % 7)) < 0) res->tm_wday += 7;

/* year & day within year */
y = 1970;
Expand Down Expand Up @@ -1221,7 +1221,7 @@ SEXP attribute_hidden do_D2POSIXlt(SEXP call, SEXP op, SEXP args, SEXP env)
int day = (int) floor(x_i);
tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
/* weekday: 1970-01-01 was a Thursday */
if ((tm.tm_wday = ((4 + day) % 7)) < 0) tm.tm_wday += 7;
if ((tm.tm_wday = (((day % 7) + 4) % 7)) < 0) tm.tm_wday += 7;

/* year & day within year */
int y = 1970, tmp, mon;
Expand Down

0 comments on commit 4f70ce0

Please sign in to comment.