@@ -72,7 +72,7 @@ CFtime <- function(definition, calendar = "standard", offsets, from, to, by, len
7272 if (is.na(intv ) || ! length(intv_unit ))
7373 stop(" Argument `by` is an invalid time interval." , call. = FALSE )
7474
75- doff <- intv * CFt $ units $ seconds [intv_unit ] / CFt $ units $ seconds [t $ cal $ unit ]
75+ doff <- intv * CFt $ units $ seconds [intv_unit ] / CFt $ units $ seconds [t $ calendar $ unit ]
7676
7777 # End point of the time series
7878 from_off <- t $ offsets # There is only a single offset at this point
@@ -84,7 +84,7 @@ CFtime <- function(definition, calendar = "standard", offsets, from, to, by, len
8484 t + seq(from = from_off + doff , by = doff , length.out = length.out [1L ] - 1L )
8585 } else {
8686 # Time series up to a finishing point
87- to_off <- t $ cal $ parse(to [1L ])$ offset
87+ to_off <- t $ calendar $ parse(to [1L ])$ offset
8888 if (is.na(to_off ))
8989 stop(" Argument `to` must be a single character timestamp value." )
9090 t + seq(from = from_off + doff , to = to_off , by = doff )
@@ -124,23 +124,23 @@ CFtime <- function(definition, calendar = "standard", offsets, from, to, by, len
124124
125125# ' @describeIn properties The definition string of the `CFTime` instance.
126126# ' @export
127- definition <- function (t ) t $ cal $ definition
127+ definition <- function (t ) t $ calendar $ definition
128128
129129# ' @describeIn properties The calendar of the `CFTime` instance.
130130# ' @export
131- calendar <- function (t ) t $ cal $ name
131+ calendar <- function (t ) t $ calendar $ name
132132
133133# ' @describeIn properties The unit of the `CFTime` instance.
134134# ' @export
135135unit <- function (t ) t $ unit
136136
137137# ' @describeIn properties The origin of the `CFTime` instance in timestamp elements.
138138# ' @export
139- origin <- function (t ) t $ cal $ origin
139+ origin <- function (t ) t $ calendar $ origin
140140
141141# ' @describeIn properties The time zone of the calendar of the `CFTime` instance as a character string.
142142# ' @export
143- timezone <- function (t ) t $ cal $ timezone
143+ timezone <- function (t ) t $ calendar $ timezone
144144
145145# ' @describeIn properties The offsets of the `CFTime` instance as a numeric vector.
146146# ' @export
@@ -472,7 +472,7 @@ slice <- function(x, extremes, rightmost.closed = FALSE) {
472472# ' e2 <- CFtime("days since 1850-01-01 00:00:00", "standard", 0:364)
473473# ' e1 == e2
474474" ==.CFTime" <- function (e1 , e2 )
475- e1 $ cal $ is_equivalent(e2 $ cal ) &&
475+ e1 $ calendar $ is_equivalent(e2 $ calendar ) &&
476476 length(e1 $ offsets ) == length(e2 $ offsets ) &&
477477 all(e1 $ offsets == e2 $ offsets )
478478
@@ -527,19 +527,19 @@ slice <- function(x, extremes, rightmost.closed = FALSE) {
527527" +.CFTime" <- function (e1 , e2 ) {
528528 diff <- NULL
529529 new_time <- if (inherits(e2 , " CFTime" )) {
530- if (! e1 $ cal $ is_compatible(e2 $ cal )) stop(" Calendars not compatible" , call. = FALSE ) # nocov
531- if (all(e1 $ cal $ origin [1 : 6 ] == e2 $ cal $ origin [1 : 6 ]))
532- CFTime $ new(e1 $ cal $ definition , e1 $ cal $ name , c(e1 $ offsets , e2 $ offsets ))
530+ if (! e1 $ calendar $ is_compatible(e2 $ calendar )) stop(" Calendars not compatible" , call. = FALSE ) # nocov
531+ if (all(e1 $ calendar $ origin [1 : 6 ] == e2 $ calendar $ origin [1 : 6 ]))
532+ CFTime $ new(e1 $ calendar $ definition , e1 $ calendar $ name , c(e1 $ offsets , e2 $ offsets ))
533533 else {
534- diff <- e1 $ cal $ parse(paste(e2 $ cal $ origin_date , e2 $ cal $ origin_time ))$ offset
535- CFTime $ new(e1 $ cal $ definition , e1 $ cal $ name , c(e1 $ offsets , e2 $ offsets + diff ))
534+ diff <- e1 $ calendar $ parse(paste(e2 $ calendar $ origin_date , e2 $ calendar $ origin_time ))$ offset
535+ CFTime $ new(e1 $ calendar $ definition , e1 $ calendar $ name , c(e1 $ offsets , e2 $ offsets + diff ))
536536 }
537537 } else if (is.numeric(e2 ) && .validOffsets(e2 )) {
538- CFTime $ new(e1 $ cal $ definition , e1 $ cal $ name , c(e1 $ offsets , e2 ))
538+ CFTime $ new(e1 $ calendar $ definition , e1 $ calendar $ name , c(e1 $ offsets , e2 ))
539539 } else {
540- time <- e1 $ cal $ parse(e2 )
540+ time <- e1 $ calendar $ parse(e2 )
541541 if (anyNA(time $ year )) stop(" Argument `e2` contains invalid timestamps" , call. = FALSE ) # nocov
542- CFTime $ new(e1 $ cal $ definition , e1 $ cal $ name , c(e1 $ offsets , time $ offset ))
542+ CFTime $ new(e1 $ calendar $ definition , e1 $ calendar $ name , c(e1 $ offsets , time $ offset ))
543543 }
544544
545545 if (! is.null(be1 <- e1 $ bounds ) && ! is.null(be2 <- e2 $ bounds )) {
@@ -561,13 +561,13 @@ slice <- function(x, extremes, rightmost.closed = FALSE) {
561561" +.CFClimatology" <- function (c1 , c2 ) {
562562 if (! inherits(c2 , " CFClimatology" ))
563563 stop(" Can only merge a `CFClimatology` instance to another `CFClimatology`" )
564- if (! c1 $ cal $ is_compatible(c2 $ cal )) stop(" Calendars not compatible" , call. = FALSE ) # nocov
564+ if (! c1 $ calendar $ is_compatible(c2 $ calendar )) stop(" Calendars not compatible" , call. = FALSE ) # nocov
565565
566- if (all(c1 $ cal $ origin [1 : 6 ] == c2 $ cal $ origin [1 : 6 ]))
567- CFClimatology $ new(c1 $ cal $ definition , c1 $ cal $ name , c(c1 $ offsets , c2 $ offsets ), cbind(c1 $ bounds , c2 $ bounds ))
566+ if (all(c1 $ calendar $ origin [1 : 6 ] == c2 $ calendar $ origin [1 : 6 ]))
567+ CFClimatology $ new(c1 $ calendar $ definition , c1 $ calendar $ name , c(c1 $ offsets , c2 $ offsets ), cbind(c1 $ bounds , c2 $ bounds ))
568568 else {
569- diff <- c1 $ cal $ parse(paste(c2 $ cal $ origin_date , c2 $ cal $ origin_time ))$ offset
570- CFClimatology $ new(c1 $ cal $ definition , c1 $ cal $ name , c(c1 $ offsets , c2 $ offsets + diff ), cbind(c1 $ bounds , c2 $ bounds + diff ))
569+ diff <- c1 $ calendar $ parse(paste(c2 $ calendar $ origin_date , c2 $ calendar $ origin_time ))$ offset
570+ CFClimatology $ new(c1 $ calendar $ definition , c1 $ calendar $ name , c(c1 $ offsets , c2 $ offsets + diff ), cbind(c1 $ bounds , c2 $ bounds + diff ))
571571 }
572572}
573573
@@ -840,13 +840,13 @@ month_days <- function(t, x = NULL) {
840840 stopifnot(inherits(t , " CFTime" ))
841841
842842 if (is.null(x ))
843- return (t $ cal $ month_days())
843+ return (t $ calendar $ month_days())
844844 else {
845845 if (! (is.character(x ))) stop(" Argument `x` must be a character vector of dates in 'YYYY-MM-DD' format" )
846846
847- ymd <- t $ cal $ parse(x )
847+ ymd <- t $ calendar $ parse(x )
848848 if (anyNA(ymd $ year )) warning(" Some dates could not be parsed. Result contains `NA` values." , call. = FALSE )
849- return (t $ cal $ month_days(ymd ))
849+ return (t $ calendar $ month_days(ymd ))
850850 }
851851}
852852
@@ -908,14 +908,14 @@ month_days <- function(t, x = NULL) {
908908# ' parse_timestamps(t, timestamps)
909909parse_timestamps <- function (t , x ) {
910910 stopifnot(is.character(x ), inherits(t , " CFTime" ))
911- if (t $ cal $ unit > 4 ) stop(" Parsing of timestamps on a 'month' or 'year' time unit is not supported." , call. = FALSE )
911+ if (t $ calendar $ unit > 4 ) stop(" Parsing of timestamps on a 'month' or 'year' time unit is not supported." , call. = FALSE )
912912
913- out <- t $ cal $ parse(x )
913+ out <- t $ calendar $ parse(x )
914914 if (anyNA(out $ year ))
915915 warning(" Some dates could not be parsed. Result contains `NA` values." ) # nocov
916916 if (length(unique(na.omit(out $ tz ))) > 1 )
917917 warning(" Timestamps have multiple time zones. Some or all may be different from the calendar time zone." ) # nocov
918- else if (out $ tz [1 ] != t $ cal $ timezone )
918+ else if (out $ tz [1 ] != t $ calendar $ timezone )
919919 warning(" Timestamps have time zone that is different from the calendar." ) # nocov
920920 out
921921}
0 commit comments