Skip to content

Commit

Permalink
Merge branch 'main' into roster-status-dict
Browse files Browse the repository at this point in the history
  • Loading branch information
tanho63 authored Aug 27, 2024
2 parents 9d3b7c3 + 8a943b3 commit 7c8fb59
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nflreadr
Title: Download 'nflverse' Data
Version: 1.4.1.00
Version: 1.4.1.02
Authors@R: c(
person("Tan", "Ho", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8388-5155")),
Expand Down Expand Up @@ -49,4 +49,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# nflreadr (development version)


- nflreadr now exports the variable `nflreadr::nflverse_data_timezone` which defines the standard timezone
across all nflverse data. When printing to the console, nflreadr will convert timestamps to the user local timezone.
- Added several player name mappings (#249, #253)

---

Expand Down
6 changes: 6 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,9 @@
#' \item{value attribute}{The "correct" name.}
#' }
"team_abbr_mapping_norelocate"

#' nflverse Timezone
#'
#' A character string defining the default timezone for data across the nflverse
#'
"nflverse_data_timezone"
12 changes: 9 additions & 3 deletions R/utils_nflverse_data_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ print.nflverse_data <- function(x,...){
cli::cli_rule("{.emph nflverse {attr(x,'nflverse_type')}}")

if(!is.null(attr(x,'nflverse_timestamp'))) {
cli::cli_alert_info(
"Data updated: {.field {format(attr(x,'nflverse_timestamp'), tz = Sys.timezone(), usetz = TRUE)}}"
# Print a formatted string in local timezone
timestamp <- format(
# the attribute is character so we have to convert it to POSIX to be able
# to convert the timezone to the local one
as.POSIXct(attr(x,'nflverse_timestamp'), tz = nflreadr::nflverse_data_timezone),
tz = Sys.timezone(),
usetz = TRUE
)
cli::cli_alert_info("Data updated: {.field {timestamp}}")
}

NextMethod(print,x)
Expand All @@ -45,7 +51,7 @@ as.nflverse_data <- function(df, nflverse_type = NULL, ...){
(length(dots) > 0 | !is.null(nflverse_type)) &&
is.null(attr(df, "nflverse_timestamp"))
){
data.table::setattr(df, "nflverse_timestamp", Sys.time())
data.table::setattr(df, "nflverse_timestamp", format(Sys.time(), tz = nflreadr::nflverse_data_timezone, usetz = TRUE))
}

return(df)
Expand Down
22 changes: 21 additions & 1 deletion data-raw/clean_player_names.csv
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,24 @@ Janoris Jenkins,Jackrabbit Jenkins
Deonte Harty,Deonte Harris
Shaquille Leonard,Darius Leonard
Robbie Anderson,Robby Anderson
Tank Dell,Nathaniel Dell
Tank Dell,Nathaniel Dell
Julius Brents,JuJu Brents
Tariq Woolen,Riq Woolen
Jartavius Martin,Quan Martin
Marquise Brown,Hollywood Brown
YaYa Diaby,Yaya Diaby
Michael Danna,Mike Danna
Ogbonnia Okoronkwo,Ogbo Okoronkwo
Cedrick Wilson,Ced Wilson
Josh Uche,Joshua Uche
Patrick Jones,Pat Jones
Adetokunbo Ogundeji,Ade Ogundeji
Daxton Hill,Dax Hill
Zachary Carter,Zach Carter
Chigoziem Okonkwo,Chig Okonkwo
Andrew Ogletree,Drew Ogletree
Nate Landman,Nathan Landman
DeVon Achane,Devon Achane
Demario Douglas,DeMario Douglas
Michael Hall,Mike Hall
Andru Phillips,Dru Phillips
2 changes: 2 additions & 0 deletions data-raw/nflverse_data_timezone.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nflverse_data_timezone <- "America/Toronto"
usethis::use_data(nflverse_data_timezone, overwrite = TRUE)
Binary file modified data/dictionary_combine.rda
Binary file not shown.
Binary file modified data/dictionary_contracts.rda
Binary file not shown.
Binary file modified data/dictionary_depth_charts.rda
Binary file not shown.
Binary file modified data/dictionary_draft_picks.rda
Binary file not shown.
Binary file modified data/dictionary_espn_qbr.rda
Binary file not shown.
Binary file modified data/dictionary_ff_opportunity.rda
Binary file not shown.
Binary file modified data/dictionary_ff_playerids.rda
Binary file not shown.
Binary file modified data/dictionary_ff_rankings.rda
Binary file not shown.
Binary file modified data/dictionary_ftn_charting.rda
Binary file not shown.
Binary file modified data/dictionary_injuries.rda
Binary file not shown.
Binary file modified data/dictionary_nextgen_stats.rda
Binary file not shown.
Binary file modified data/dictionary_participation.rda
Binary file not shown.
Binary file modified data/dictionary_pfr_passing.rda
Binary file not shown.
Binary file modified data/dictionary_player_stats.rda
Binary file not shown.
Binary file modified data/dictionary_rosters.rda
Binary file not shown.
Binary file modified data/dictionary_schedules.rda
Binary file not shown.
Binary file modified data/dictionary_snap_counts.rda
Binary file not shown.
Binary file modified data/dictionary_trades.rda
Binary file not shown.
Binary file added data/nflverse_data_timezone.rda
Binary file not shown.
Binary file modified data/player_name_mapping.rda
Binary file not shown.
Binary file modified data/team_abbr_mapping.rda
Binary file not shown.
Binary file modified data/team_abbr_mapping_norelocate.rda
Binary file not shown.
16 changes: 16 additions & 0 deletions man/nflverse_data_timezone.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reference:
- "load_ftn_charting"
- "nflverse_download"
- "nflverse_releases"
- "nflverse_data_timezone"
- title: Load ffverse data
contents:
- "load_ff_playerids"
Expand Down

0 comments on commit 7c8fb59

Please sign in to comment.