Skip to content

Commit

Permalink
as proposed by Miguel
Browse files Browse the repository at this point in the history
  • Loading branch information
christophsax committed Oct 20, 2024
1 parent 0a0a4a2 commit e399a0c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/convert_exact.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ seconds_in_year <- function(year, tz) {
#' @srrstats {G2.4c} *explicit conversion to character via `as.character()` (and not `paste` or `paste0`)*
#' @noRd
seconds_at_start_of_year <- function(year, tz) {
as.numeric(as.POSIXct(paste0(as.character(year), "-01-01"), tz = tz))
diff(c(
as.numeric(as.POSIXct("1970-01-01", tz = tz)),
as.numeric(as.POSIXct(paste0(as.character(year), "-01-01"), tz = tz))
))
}


Expand All @@ -43,6 +46,7 @@ dectime_to_POSIXct <- function(x) {
seconds_since_70 <-
seconds_at_start_of_year(year, tz = "") +
seconds_in_year(year, tz = "") * intra
seconds_since_70 <- round(seconds_since_70, 4)
as.POSIXct(seconds_since_70, origin = "1970-01-01", tz = "")
}

Expand Down

0 comments on commit e399a0c

Please sign in to comment.