R/getters.R

Defines functions get_index_quo get_index_char get_index_col get_.index_col get_index_time_zone get_index_class get_index_dispatcher get_default_time_zone get_index_col_time_zone get_index_col_class

# Getters for tbl_time objects -------------------------------------------------

get_index_quo <- function(x) {
  attr(x, "index_quo")
}

get_index_char <- function(x) {
  rlang::quo_name(get_index_quo(x))
}

get_index_col <- function(x) {
  x[[get_index_char(x)]]
}

get_.index_col <- function(x) {
  to_posixct_numeric(get_index_col(x))
}

get_index_time_zone <- function(x) {
  attr(x, "index_time_zone")
}

get_index_class <- function(x) {
  class(get_index_col(x))[[1]]
}

get_index_dispatcher <- function(x) {
  make_dummy_dispatch_obj(get_index_class(x))
}

# Getters in tbl_time object creation ------------------------------------------

# Get the default time zone. Use a non daylight savings default
# to avoid issues like issue #31
get_default_time_zone <- function() {
  "UTC"
}

get_index_col_time_zone <- function(x) {
  attr(x, "tzone") %||% get_default_time_zone()
}

get_index_col_class <- function(x) {
  class(x)[[1]]
}
DavisVaughan/tibbletime3 documentation built on May 28, 2019, 12:25 p.m.