@@ -61,6 +61,27 @@ epirange <- function(from, to) {
6161 structure(list (from = from , to = to ), class = " EpiRange" )
6262}
6363
64+ # ' @export
65+ print.EpiRange <- function (x , ... ) {
66+ if (nchar(x $ from ) == 8 ) {
67+ date_type <- " Days" # nolint: object_usage_linter
68+ x $ from <- as.Date(as.character(x $ from ), " %Y%m%d" )
69+ x $ to <- as.Date(as.character(x $ to ), " %Y%m%d" )
70+ } else if (nchar(x $ from ) == 6 ) {
71+ date_type <- " Epiweeks" # nolint: object_usage_linter
72+ x $ from <- paste0(
73+ substr(x $ from , 1 , 4 ), " w" , substr(x $ from , 5 , 6 )
74+ )
75+ x $ to <- paste0(
76+ substr(x $ to , 1 , 4 ), " w" , substr(x $ to , 5 , 6 )
77+ )
78+ }
79+
80+ cli :: cli_h1(" <EpiRange> object:" )
81+ cli :: cli_bullets(
82+ " {date_type} from {x$from} to {x$to}"
83+ )
84+ }
6485
6586# ' Timeset formats for specifying dates
6687# '
@@ -86,7 +107,6 @@ epirange <- function(from, to) {
86107# ' @name timeset
87108NULL
88109
89-
90110create_epidata_field_info <- function (name ,
91111 type ,
92112 description = " " ,
@@ -117,6 +137,13 @@ create_epidata_field_info <- function(name,
117137 )
118138}
119139
140+ # ' @export
141+ print.EpidataFieldInfo <- function (x , ... ) {
142+ cli :: cli_h1(" <EpidataFieldInfo> object:" )
143+ # Print all non-class fields.
144+ cli :: cli_dl(x [attr(x , " names" )])
145+ }
146+
120147parse_value <- function (info , value , disable_date_parsing = FALSE ) {
121148 stopifnot(inherits(info , " EpidataFieldInfo" ))
122149
0 commit comments