View | Details | Raw Unified | Return to bug 16761 | Differences between
and this patch

Collapse All | Expand All

(-)prettyDate/prettyDate.R (-2 / +2 lines)
Lines 49-55 Link Here
49
			  list(format = paste("%b", "%d", sep = sep))))
49
			  list(format = paste("%b", "%d", sep = sep))))
50
    }
50
    }
51
    else if(D < 1) { # unique values / sub-second ranges: [? or use "1 ms" steps below?]
51
    else if(D < 1) { # unique values / sub-second ranges: [? or use "1 ms" steps below?]
52
	m <- min(30, max(D == 0, n/2 - 1)) # "- 1" ==> better match for 'n'
52
	m <- min(30, max(D == 0, n/2))
53
	zz <- structure(c(floor(nzz[1] - m), ceiling(nzz[2] + m)),
53
	zz <- structure(c(floor(nzz[1] - m), ceiling(nzz[2] + m)),
54
			class = class(x), tzone = attr(x, "tzone"))
54
			class = class(x), tzone = attr(x, "tzone"))
55
    }
55
    }
Lines 119-125 Link Here
119
    ## bump it up if below acceptable threshold
119
    ## bump it up if below acceptable threshold
120
    while ((init.n <- length(init.at) - 1L) < min.n) {
120
    while ((init.n <- length(init.at) - 1L) < min.n) {
121
	if(init.i == 1L)
121
	if(init.i == 1L)
122
	    break # and live with it instead of error
122
	    stop("range too small for 'min.n'")
123
	init.i <- init.i - 1L
123
	init.i <- init.i - 1L
124
	init.at <- calcSteps(steps[[init.i]])
124
	init.at <- calcSteps(steps[[init.i]])
125
    }
125
    }
(-)prettyDate/reg-tests-1c.R (-5 / +3 lines)
Lines 1399-1405 Link Here
1399
chkPretty <- function(obj, n = 5, ..., max.D = 1) {
1399
chkPretty <- function(obj, n = 5, ..., max.D = 1) {
1400
    pr <- pretty(obj, n=n, ...)
1400
    pr <- pretty(obj, n=n, ...)
1401
    ## if debugging: pr <- grDevices:::prettyDate(obj, n=n, ...)
1401
    ## if debugging: pr <- grDevices:::prettyDate(obj, n=n, ...)
1402
    stopifnot(abs(length(pr) - n) <= max.D,
1402
    stopifnot(abs(length(pr) - (n+1)) <= max.D,
1403
	      length(unique(diff(pr))) == 1, # <==> must be equidistant
1403
	      length(unique(diff(pr))) == 1, # <==> must be equidistant
1404
	      min(pr) <= min(obj), max(obj) <= max(pr))
1404
	      min(pr) <= min(obj), max(obj) <= max(pr))
1405
    invisible(pr)
1405
    invisible(pr)
Lines 1417-1432 Link Here
1417
(p1   <- chkPretty(MTbd))
1417
(p1   <- chkPretty(MTbd))
1418
stopifnot(
1418
stopifnot(
1419
    identical(p1, seqDp("1960-02-08", "1960-02-13")) ,
1419
    identical(p1, seqDp("1960-02-08", "1960-02-13")) ,
1420
    identical(attr(p1, "labels"), paste("Feb", time2d(8:13))),
1421
    identical(chkPretty(MTbd + rep(0,2)), p1) ,
1420
    identical(chkPretty(MTbd + rep(0,2)), p1) ,
1422
    identical(chkPretty(MTbd +  0:1), p1) ,
1421
    identical(chkPretty(MTbd +  0:1), p1) ,
1423
    identical(chkPretty(MTbd + -1:1), p1) ,
1422
    identical(chkPretty(MTbd + -1:1), p1) ,
1424
    identical(chkPretty(MTbd +  0:3), seqDp("1960-02-09", "1960-02-14")) )
1423
    identical(chkPretty(MTbd +  0:3), seqDp("1960-02-09", "1960-02-14")) )
1425
## all pretty() above gave length >= 5 answer (with duplicated values!) in R <= 3.2.3!
1424
## all pretty() above gave length >= 5 answer (with duplicated values!) in R <= 3.2.3!
1426
## and length 1 or 2 instead of about 5 in R 3.2.4
1425
## and length 1 or 2 instead of about 6 in R 3.2.4
1427
(p2 <- chkPretty(as.POSIXct("2002-02-02 02:02", tz = "GMT-1"), n = 5, min.n = 5))
1426
(p2 <- chkPretty(as.POSIXct("2002-02-02 02:02", tz = "GMT-1"), n = 5, min.n = 5))
1428
stopifnot(identical(p2, structure(1012611718 + (0:4), class = c("POSIXct", "POSIXt"),
1427
stopifnot(length(p2) >= 6)
1429
                                  tzone = "GMT-1", labels = time2d(58:62))))
1430
## failed in R 3.2.4
1428
## failed in R 3.2.4
1431
1429
1432
1430

Return to bug 16761