-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding parser for timespan from iso8601 (#26)
- Loading branch information
Showing
22 changed files
with
445 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#' start S3 generic | ||
#' | ||
#' A generic method to retrieve the start of an object | ||
#' | ||
#' @param x An object to retrieve the start from | ||
#' @param ... Additional arguments passed to methods | ||
#' | ||
start <- function(x, ...) { | ||
UseMethod("start") | ||
} | ||
|
||
#' @importFrom utils head | ||
#' @rawNamespace S3method(stats::start,timespan) | ||
#' @export | ||
start.timespan <- function(x, ...) { | ||
cols <- utils::head(dimnames(vctrs::field(x, "tmspn_arr"))[[2]], -1L) | ||
dns <- dimnames(vctrs::field(x, "tmspn_arr")) | ||
as.parttime(array( | ||
vctrs::field(x, "tmspn_arr")[, cols, "lb"], | ||
dim = c(length(x), length(cols)), | ||
dimnames = list(dns[[1L]], cols) | ||
)) | ||
} | ||
|
||
#' end S3 generic | ||
#' | ||
#' A generic method to retrieve the end of an object | ||
#' | ||
#' @param x An object to retrieve the end from | ||
#' @param ... Additional arguments passed to methods | ||
#' | ||
end <- function(x, ...) { | ||
UseMethod("end") | ||
} | ||
|
||
#' @importFrom utils head | ||
#' @rawNamespace S3method(stats::end,timespan) | ||
#' @export | ||
end.timespan <- function(x, ...) { | ||
cols <- utils::head(dimnames(vctrs::field(x, "tmspn_arr"))[[2]], -1L) | ||
dns <- dimnames(vctrs::field(x, "tmspn_arr")) | ||
as.parttime(array( | ||
vctrs::field(x, "tmspn_arr")[, cols, "ub"], | ||
dim = c(length(x), length(cols)), | ||
dimnames = list(dns[[1L]], cols) | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.