data-raw/fy23_submission_calendar.R

library(tidyverse)
library(lubridate)
library(Wavelength)
# library(rvest)

fy <- 2023


fy_date <- seq.Date(make_date(fy-1, 11, 1), make_date(fy, 10, 30), by = 1)

df_cal <- tibble(date = fy_date) %>%
  mutate(is.weekend = wday(date, week_start = 1) > 5,
         is.holiday = date %in% opm_holiday$date_holiday_obs,
         is.businessday = is.weekend == FALSE & is.holiday == FALSE,
         month = month(date),
         day = day(date))

df_subm <- df_cal %>%
  group_by(month) %>%
  filter(is.businessday,
         day >= 15) %>%
  slice_head() %>%
  ungroup() %>%
  arrange(date)

df_subm %>%
  pull(date) %>%
  clipr::write_clip()


# url <- "https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/"
#
# contents <- read_html(url)
#
# # contents %>%
# #   html_element(css = "#2023")
#
# tbl <- NULL
#
# sections <- contents %>%
#   html_node("#frmMain") %>%
#   html_nodes("section")
#
# sections %>%
#   walk(function(.s){
#     yr <- .s %>%
#       html_node("h1") %>%
#       html_text()
#
#     if (yr == 2023)
#       tbl <<- .s %>%
#         html_node("tbody") %>%
#         html_nodes("tr")
#   })
#
# h_dates <- tbl %>%
#   html_nodes("td:nth_child(1)") %>%
#   html_text()
#
# h_names <- tbl %>%
#   html_nodes("td:nth_child(2)") %>%
#   html_text()
#
# tibble(
#   date = h_dates,
#   name = h_names
# )
USAID-OHA-SI/Wavelength documentation built on March 24, 2023, 10:07 a.m.