R/wa_format_date.R

Defines functions wa_format_date

Documented in wa_format_date

# Generated by tools/generate_components.R. Do not edit by hand.
# nolint start: object_usage_linter.

#' Create a `wa-format-date` component
#'
#' Generated wrapper for the Web Awesome `wa-format-date` component.
#' Generated from Web Awesome metadata.
#'
#' @param ... Child content for the component's default slot.
#' @param id Optional DOM id attribute for HTML, CSS, and JS targeting.
#' @param class Optional CSS class string.
#' @param style Optional inline CSS style string.
#' @param date Default: `new Date()`. The date/time to format. If not set,
#' the current date and time will be used. When passing a string, it's
#' strongly recommended to use the ISO 8601 format to ensure timezones are
#' handled correctly. To convert a date to this format in JavaScript, use
#' `date.toISOString()`.
#' @param day Enumerated string. Allowed values: `2-digit`, `numeric`. The
#' format for displaying the day.
#' @param dir String. Optional Web Awesome attribute.
#' @param era Enumerated string. Allowed values: `long`, `narrow`,
#' `short`. The format for displaying the era.
#' @param hour Enumerated string. Allowed values: `2-digit`, `numeric`.
#' The format for displaying the hour.
#' @param hour_format Enumerated string. Allowed values: `12`, `24`,
#' `auto`. Default: `auto`. The format for displaying the hour.
#' @param lang String. Optional Web Awesome attribute.
#' @param minute Enumerated string. Allowed values: `2-digit`, `numeric`.
#' The format for displaying the minute.
#' @param month Enumerated string. Allowed values: `2-digit`, `long`,
#' `narrow`, `numeric`, `short`. The format for displaying the month.
#' @param second Enumerated string. Allowed values: `2-digit`, `numeric`.
#' The format for displaying the second.
#' @param time_zone String. The time zone to express the time in.
#' @param time_zone_name Enumerated string. Allowed values: `long`,
#' `short`. The format for displaying the time.
#' @param weekday Enumerated string. Allowed values: `long`, `narrow`,
#' `short`. The format for displaying the weekday.
#' @param year Enumerated string. Allowed values: `2-digit`, `numeric`.
#' The format for displaying the year.
#'
#' @section Shiny Bindings:
#' None.
#'
#' @return An HTML tag for the component.
#'
#' @export
wa_format_date <- function(
  ...,
  id = NULL,
  class = NULL,
  style = NULL,
  date = NULL,
  day = NULL,
  dir = NULL,
  era = NULL,
  hour = NULL,
  hour_format = NULL,
  lang = NULL,
  minute = NULL,
  month = NULL,
  second = NULL,
  time_zone = NULL,
  time_zone_name = NULL,
  weekday = NULL,
  year = NULL
) {
  children <- list(...)

  if (!is.null(day)) {
    day <- .wa_match_arg(
      day,
      "day",
      c(
        "2-digit",
        "numeric"
      )
    )
  }

  if (!is.null(era)) {
    era <- .wa_match_arg(
      era,
      "era",
      c(
        "long",
        "narrow",
        "short"
      )
    )
  }

  if (!is.null(hour)) {
    hour <- .wa_match_arg(
      hour,
      "hour",
      c(
        "2-digit",
        "numeric"
      )
    )
  }

  if (!is.null(hour_format)) {
    hour_format <- .wa_match_arg(
      hour_format,
      "hour_format",
      c(
        "12",
        "24",
        "auto"
      )
    )
  }

  if (!is.null(minute)) {
    minute <- .wa_match_arg(
      minute,
      "minute",
      c(
        "2-digit",
        "numeric"
      )
    )
  }

  if (!is.null(month)) {
    month <- .wa_match_arg(
      month,
      "month",
      c(
        "2-digit",
        "long",
        "narrow",
        "numeric",
        "short"
      )
    )
  }

  if (!is.null(second)) {
    second <- .wa_match_arg(
      second,
      "second",
      c(
        "2-digit",
        "numeric"
      )
    )
  }

  if (!is.null(time_zone_name)) {
    time_zone_name <- .wa_match_arg(
      time_zone_name,
      "time_zone_name",
      c(
        "long",
        "short"
      )
    )
  }

  if (!is.null(weekday)) {
    weekday <- .wa_match_arg(
      weekday,
      "weekday",
      c(
        "long",
        "narrow",
        "short"
      )
    )
  }

  if (!is.null(year)) {
    year <- .wa_match_arg(
      year,
      "year",
      c(
        "2-digit",
        "numeric"
      )
    )
  }

  attrs <- .wa_normalize_attrs(
    list(
      "id" = id,
      "class" = class,
      "style" = style,
      "date" = date,
      "day" = day,
      "dir" = dir,
      "era" = era,
      "hour" = hour,
      "hour-format" = hour_format,
      "lang" = lang,
      "minute" = minute,
      "month" = month,
      "second" = second,
      "time-zone" = time_zone,
      "time-zone-name" = time_zone_name,
      "weekday" = weekday,
      "year" = year
    ),
    boolean_names = character(),
    boolean_arg_names = NULL
  )

  do.call(
    .wa_component,
    c(
      list("wa-format-date", .attrs = attrs),
      children
    )
  )
}
# nolint end

Try the shiny.webawesome package in your browser

Any scripts or data that you put into this service are public.

shiny.webawesome documentation built on April 22, 2026, 1:09 a.m.