Skip to content

Commit

Permalink
Simplify adding integer mark.
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian8207 committed Jun 25, 2024
1 parent b91cda4 commit 13781e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions R/dateUtilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ addDaysQuery <- function(cdm,
cli::cli_abort("type must be day or year")
}

number <- as.integer(number)
number <- glue::glue("{as.integer(number)}L")

if(type == "day"){
q <- glue::glue("clock::add_days({variable} , {(number)}L)")
q <- glue::glue("clock::add_days({variable} , {(number)})")
}

if(type == "year"){
if(omopgenerics::cdmSourceType(cdm) == "spark"){
# https://github.com/darwin-eu-dev/IncidencePrevalence/issues/395
number_days_to_years <- as.integer(number*365)
q <- glue::glue("clock::add_days({variable}, {(number_days_to_years)}L)")
q <- glue::glue("clock::add_days({variable}, {(number_days_to_years)})")
} else {
q <- glue::glue("clock::add_years({variable}, {(number)}L)")
q <- glue::glue("clock::add_years({variable}, {(number)})")
}
}

Expand All @@ -42,19 +42,19 @@ minusDaysQuery <- function(cdm,
cli::cli_abort("type must be day or year")
}

number <- as.integer(number)
number <- glue::glue("{as.integer(number)}L")


if(type == "day"){
q <- glue::glue("clock::add_days({variable} , {(number)}L)")
q <- glue::glue("clock::add_days({variable} , {(number)})")
}
if(type == "year"){
if(omopgenerics::cdmSourceType(cdm) == "spark"){
# https://github.com/darwin-eu-dev/IncidencePrevalence/issues/395
number_days_to_years <- as.integer(number*365)
q <- glue::glue("clock::add_days({variable}, {(number_days_to_years)}L)")
q <- glue::glue("clock::add_days({variable}, {(number_days_to_years)})")
} else {
q <- glue::glue("clock::add_years({variable} , {(number)}L)")
q <- glue::glue("clock::add_years({variable} , {(number)})")
}
}

Expand Down

0 comments on commit 13781e6

Please sign in to comment.