what_month: What month is it?

View source: R/time_fun.R

what_monthR Documentation

What month is it?

Description

what_month provides a satisficing version of to determine the month corresponding to a given date.

Usage

what_month(when = Sys.Date(), abbr = FALSE, as_integer = FALSE)

Arguments

when

Date (as a scalar or vector). Default: when = NA. Using as.Date(when) to convert strings into dates, and Sys.Date(), if when = NA.

abbr

Boolean: Return abbreviated? Default: abbr = FALSE.

as_integer

Boolean: Return as integer? Default: as_integer = FALSE.

Details

what_month returns the month of when or Sys.Date() (as a name or number).

See Also

what_week() function to obtain weeks; what_date() function to obtain dates; cur_time() function to print the current time; cur_date() function to print the current date; now() function of the lubridate package; Sys.time() function of base R.

Other date and time functions: change_time(), change_tz(), cur_date(), cur_time(), days_in_month(), diff_dates(), diff_times(), diff_tz(), is_leap_year(), what_date(), what_time(), what_wday(), what_week(), what_year(), zodiac()

Examples

what_month()
what_month(abbr = TRUE)
what_month(as_integer = TRUE)

# with date vector (as characters):
ds <- c("2020-01-01", "2020-02-29", "2020-12-24", "2020-12-31")
what_month(when = ds)
what_month(when = ds, abbr = TRUE, as_integer = FALSE)
what_month(when = ds, abbr = TRUE, as_integer = TRUE)

# with time vector (strings of POSIXct times):
ts <- c("2020-02-29 10:11:12 CET", "2020-12-31 23:59:59")
what_month(ts)
        

ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.