Skip to content

Return localized weekdays for wday() #401

Description

@alberthkcheng

wday() always returns English names of weekdays. I made the following changes using date_names_lang in readr, to overcome this. Is there solution exists without using readr?

Also, the same applies to month.

wday.numeric <- function (x, label = FALSE, abbr = TRUE, language="en") 
{
  if (!label) 
    return(x)
  if (abbr) {
    labels <- date_names_lang(language)$day_ab
  }
  else {
    labels <- date_names_lang(language)$day
  }
  ordered(x, levels = 1:7, labels = labels)
}

wday(ymd(160408),label=TRUE,language="ko")
# [1] 금
# Levels: 일 < 월 < 화 < 수 < 목 < 금 < 토

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions