Skip to content

Language issue in .generate_output_dates(df_info, freq = "B", h) #52

Description

@bergarog

In my setup, weekdays(Sys.Date() + 0:6) returns c("Freitag", "Samstag", "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag"), meaning weekday names are in my system's locale (German).
As a result, the filtering condition:

dt <- dt[!weekdays(dt) %in% c("Saturday", "Sunday")]

does not work because "Saturday" and "Sunday" do not match "Samstag" and "Sonntag".

Issue in R/generate_output_dates.R

else if(freq %in% c("B")){
      dt <- seq(from = start_date, by = "day", length.out = h+1+ceiling(h/5)*2+2) # ceiling(h/5)*2+2 ~ number of weeks*2 days (Saturday and Sunday) plus an extra weekend to be on the safe side
      dt <- dt[!weekdays(dt) %in% c("Saturday", "Sunday")]
      dt <- format(dt, "%Y-%m-%d")
    }

Possible Fix:
Using lubridate::wday(dt) could possibly resolve this issue:

dt <- dt[lubridate::wday(dt) %in% 2:6]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions