lubridate
package has required function "days_in_month" with respect to leapyears.
Your example:
date <- as.Date("2011-02-23", "%Y-%m-%d")
lubridate::days_in_month(date)
# Feb
# 28
Leap year (2016):
date_leap <- as.Date("2016-02-23", "%Y-%m-%d")
lubridate::days_in_month(date_leap)
# Feb
# 29
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…