Skip to content

Commit 24bc301

Browse files
committed
two refinements for Date.cpp required on Windows
1 parent f0442a0 commit 24bc301

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2017-01-04 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/Date.cpp (Rcpp): Protect assignment to tm_gmtoff to not being
4+
under MinGW; could potentially bite other too-limited systems
5+
6+
* inst/unitTests/runit.Date.R (test.Datetime.formating): Condition one
7+
test out if on Windows
8+
19
2017-01-01 Dirk Eddelbuettel <[email protected]>
210

311
* inst/unitTests/runit.Date.R (test.mktime, test.gmtime): New tests

inst/unitTests/runit.Date.R

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -217,25 +217,27 @@ if (.runThisTest) {
217217
}
218218

219219
test.Datetime.formating <- function() {
220-
oldTZ <- Sys.getenv("TZ")
221-
Sys.setenv(TZ="America/Chicago")
222-
223-
olddigits <- getOption("digits.secs")
224-
options("digits.secs"=6)
225-
226-
d <- as.POSIXct("2016-12-13 14:15:16.123456")
227-
checkEquals(Datetime_format(d,"%Y-%m-%d %H:%M:%S"),
228-
format(d, "%Y-%m-%d %H:%M:%OS"),
229-
msg="Datetime.formating.default")
230-
checkEquals(Datetime_format(d, "%Y/%m/%d %H:%M:%S"),
231-
format(d, "%Y/%m/%d %H:%M:%OS"),
232-
msg="Datetime.formating.given.format")
233-
checkEquals(Datetime_ostream(d),
234-
format(d, "%Y-%m-%d %H:%M:%OS"),
235-
msg="Datetime.formating.ostream")
236-
237-
Sys.setenv(TZ=oldTZ)
238-
options("digits.secs"=olddigits)
220+
if (Sys.info()[["sysname"]] != "Windows") {
221+
oldTZ <- Sys.getenv("TZ")
222+
Sys.setenv(TZ="America/Chicago")
223+
224+
olddigits <- getOption("digits.secs")
225+
options("digits.secs"=6)
226+
227+
d <- as.POSIXct("2016-12-13 14:15:16.123456")
228+
checkEquals(Datetime_format(d,"%Y-%m-%d %H:%M:%S"),
229+
format(d, "%Y-%m-%d %H:%M:%OS"),
230+
msg="Datetime.formating.default")
231+
checkEquals(Datetime_format(d, "%Y/%m/%d %H:%M:%S"),
232+
format(d, "%Y/%m/%d %H:%M:%OS"),
233+
msg="Datetime.formating.given.format")
234+
checkEquals(Datetime_ostream(d),
235+
format(d, "%Y-%m-%d %H:%M:%OS"),
236+
msg="Datetime.formating.ostream")
237+
238+
Sys.setenv(TZ=oldTZ)
239+
options("digits.secs"=olddigits)
240+
}
239241
}
240242

241243

src/Date.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,10 @@ struct tzhead {
13471347
idays -= ip[tmp->tm_mon];
13481348
tmp->tm_mday = (int) (idays + 1);
13491349
tmp->tm_isdst = 0;
1350-
//#ifdef HAVE_TM_GMTOFF
1350+
#if ! (defined(__MINGW32__) || defined(__MINGW64__))
1351+
//#ifdef HAVE_TM_GMTOFF
13511352
tmp->tm_gmtoff = offset;
1352-
//#endif
1353+
#endif
13531354
return tmp;
13541355
}
13551356

0 commit comments

Comments
 (0)