ensure_date_format: Check date format and transform in a usable one

View source: R/utils.R

ensure_date_formatR Documentation

Check date format and transform in a usable one

Description

Check date format. If the format is wrong ('NA') an error message is printed, else it will formatted the date in the correct way (YYYY-MM-DD)

Usage

ensure_date_format(date_input)

Arguments

date_input

Date included as input

Value

A character string representing the date in 'YYYY-MM-DD' format

Examples

# Example of correct date formats
ensure_date_format("2024-08-30") # "2024-08-30"
ensure_date_format("30/08/2024") # "2024-08-30"

# Example of incorrect date formats
tryCatch(
  {
    ensure_date_format("Aug-30")
  },
  error = function(e) {
    message(e$message)
  }
)


greenfeedr documentation built on April 4, 2025, 12:22 a.m.