File: month_days.Rd

package info (click to toggle)
r-cran-cftime 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,752 kB
  • sloc: sh: 13; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,852 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api.R
\name{month_days}
\alias{month_days}
\title{Return the number of days in a month given a certain CF calendar}
\usage{
month_days(t, x = NULL)
}
\arguments{
\item{t}{The \code{CFtime} instance to use.}

\item{x}{character. An optional vector of dates as strings with format
\code{YYYY-MM-DD}. Any time part will be silently ingested.}
}
\value{
A vector indicating the number of days in each month for the vector
of dates supplied as argument \verb{x. Invalidly specified dates will result in an }NA` value. If no dates are supplied, the number of days per month for
the calendar as a vector of length 12.
}
\description{
Given a vector of dates as strings in ISO 8601 or UDUNITS format and a
\link{CFTime} object, this function will return a vector of the same length as the
dates, indicating the number of days in the month according to the calendar
specification. If no vector of days is supplied, the function will return an
integer vector of length 12 with the number of days for each month of the
calendar (disregarding the leap day for \code{standard} and \code{julian} calendars).
}
\examples{
dates <- c("2021-11-27", "2021-12-10", "2022-01-14", "2022-02-18")
t <- CFtime("days since 1850-01-01", "standard")
month_days(t, dates)

t <- CFtime("days since 1850-01-01", "360_day")
month_days(t, dates)

t <- CFtime("days since 1850-01-01", "all_leap")
month_days(t, dates)

month_days(t)
}
\seealso{
When working with factors generated by \code{\link[=CFfactor]{CFfactor()}}, it is usually
better to use \code{\link[=CFfactor_units]{CFfactor_units()}} as that will consider leap days for
non-era factors. \code{\link[=CFfactor_units]{CFfactor_units()}} can also work with other time periods
and calendar units, such as "hours per month", or "days per season".
}