File: CFCalendar.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 (284 lines) | stat: -rw-r--r-- 10,196 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CFCalendar.R
\docType{class}
\name{CFCalendar}
\alias{CFCalendar}
\title{Basic CF calendar}
\description{
This class represents a basic CF calendar. It should not be
instantiated directly; instead, use one of the descendant classes.

This internal class stores the information to represent date and time
values using the CF conventions. An instance is created by the exported
\link{CFTime} class, which also exposes the relevant properties of this class.

The following calendars are supported:

\itemize{
\item \code{\link[=CFCalendarStandard]{gregorian\\standard}}, the international standard calendar for civil use.
\item \code{\link[=CFCalendarProleptic]{proleptic_gregorian}}, the standard calendar but extending before 1582-10-15
when the Gregorian calendar was adopted.
\item \code{\link[=CFCalendarTAI]{tai}}, International Atomic Time clock with dates expressed using the Gregorian calendar.
\item \code{\link[=CFCalendarUTC]{utc}}, Coordinated Universal Time clock with dates expressed using the Gregorian calendar.
\item \code{\link[=CFCalendarJulian]{julian}}, every fourth year is a leap year (so including the years 1700, 1800, 1900, 2100, etc).
\item \code{\link[=CFCalendar365]{noleap\\365_day}}, all years have 365 days.
\item \code{\link[=CFCalendar366]{all_leap\\366_day}}, all years have 366 days.
\item \code{\link[=CFCalendar360]{360_day}}, all years have 360 days, divided over 12 months of 30 days.
}
}
\references{
https://cfconventions.org/Data/cf-conventions/cf-conventions-1.12/cf-conventions.html#calendar
}
\section{Public fields}{
\if{html}{\out{<div class="r6-fields">}}
\describe{
\item{\code{name}}{Descriptive name of the calendar, as per the CF Metadata
Conventions.}

\item{\code{definition}}{The string that defines the units and the origin, as
per the CF Metadata Conventions.}

\item{\code{unit}}{The numeric id of the unit of the calendar.}

\item{\code{origin}}{\code{data.frame} with fields for the origin of the calendar.}
}
\if{html}{\out{</div>}}
}
\section{Active bindings}{
\if{html}{\out{<div class="r6-active-bindings">}}
\describe{
\item{\code{origin_date}}{(read-only) Character string with the date of the
calendar.}

\item{\code{origin_time}}{(read-only) Character string with the time of the
calendar.}

\item{\code{timezone}}{(read-only) Character string with the time zone of the
origin of the calendar.}
}
\if{html}{\out{</div>}}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-CFCalendar-new}{\code{CFCalendar$new()}}
\item \href{#method-CFCalendar-print}{\code{CFCalendar$print()}}
\item \href{#method-CFCalendar-valid_days}{\code{CFCalendar$valid_days()}}
\item \href{#method-CFCalendar-POSIX_compatible}{\code{CFCalendar$POSIX_compatible()}}
\item \href{#method-CFCalendar-is_compatible}{\code{CFCalendar$is_compatible()}}
\item \href{#method-CFCalendar-is_equivalent}{\code{CFCalendar$is_equivalent()}}
\item \href{#method-CFCalendar-parse}{\code{CFCalendar$parse()}}
\item \href{#method-CFCalendar-offsets2time}{\code{CFCalendar$offsets2time()}}
\item \href{#method-CFCalendar-clone}{\code{CFCalendar$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-new"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-new}{}}}
\subsection{Method \code{new()}}{
Create a new CF calendar.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$new(nm, definition)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{nm}}{The name of the calendar. This must follow the CF Metadata
Conventions.}

\item{\code{definition}}{The string that defines the units and the origin, as
per the CF Metadata Conventions.}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-print"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-print}{}}}
\subsection{Method \code{print()}}{
Print information about the calendar to the console.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$print(...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{...}}{Ignored.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{self}, invisibly.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-valid_days"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-valid_days}{}}}
\subsection{Method \code{valid_days()}}{
Indicate which of the supplied dates are valid.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$valid_days(ymd)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{ymd}}{\code{data.frame} with dates parsed into their parts in columns
\code{year}, \code{month} and \code{day}. Any other columns are disregarded.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{NULL}. A warning will be generated to the effect that a
descendant class should be used for this method.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-POSIX_compatible"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-POSIX_compatible}{}}}
\subsection{Method \code{POSIX_compatible()}}{
Indicate if the time series described using this calendar
can be safely converted to a standard date-time type (\code{POSIXct},
\code{POSIXlt}, \code{Date}).

Only the 'standard' calendar and the 'proleptic_gregorian' calendar
when all dates in the time series are more recent than 1582-10-15
(inclusive) can be safely converted, so this method returns \code{FALSE} by
default to cover the majority of cases.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$POSIX_compatible(offsets)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{offsets}}{The offsets from the CFtime instance.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{FALSE} by default.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-is_compatible"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-is_compatible}{}}}
\subsection{Method \code{is_compatible()}}{
This method tests if the \code{CFCalendar} instance in argument
\code{cal} is compatible with \code{self}, meaning that they are of the same
class and have the same unit. Calendars "standard", and "gregorian" are
compatible, as are the pairs of "365_day" and "no_leap", and "366_day"
and "all_leap".
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$is_compatible(cal)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{cal}}{Instance of a descendant of the \code{CFCalendar} class.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{TRUE} if the instance in argument \code{cal} is compatible with
\code{self}, \code{FALSE} otherwise.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-is_equivalent"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-is_equivalent}{}}}
\subsection{Method \code{is_equivalent()}}{
This method tests if the \code{CFCalendar} instance in argument
\code{cal} is equivalent to \code{self}, meaning that they are of the same class,
have the same unit, and equivalent origins. Calendars "standard", and
"gregorian" are equivalent, as are the pairs of "365_day" and
"no_leap", and "366_day" and "all_leap".

Note that the origins need not be identical, but their parsed values
have to be. "2000-01" is parsed the same as "2000-01-01 00:00:00", for
instance.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$is_equivalent(cal)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{cal}}{Instance of a descendant of the \code{CFCalendar} class.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
\code{TRUE} if the instance in argument \code{cal} is equivalent to
\code{self}, \code{FALSE} otherwise.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-parse"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-parse}{}}}
\subsection{Method \code{parse()}}{
Parsing a vector of date-time character strings into parts.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$parse(d)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{d}}{character. A character vector of date-times.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A \code{data.frame} with columns year, month, day, hour, minute,
second, time zone, and offset. Invalid input data will appear as \code{NA}.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-offsets2time"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-offsets2time}{}}}
\subsection{Method \code{offsets2time()}}{
Decompose a vector of offsets, in units of the calendar, to
their timestamp values. This adds a specified amount of time to the
origin of a \code{CFTime} object.

This method may introduce inaccuracies where the calendar unit is
"months" or "years", due to the ambiguous definition of these units.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$offsets2time(offsets = NULL)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{offsets}}{Vector of numeric offsets to add to the origin of the
calendar.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A \code{data.frame} with columns for the timestamp elements and as
many rows as there are offsets.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-CFCalendar-clone"></a>}}
\if{latex}{\out{\hypertarget{method-CFCalendar-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{CFCalendar$clone(deep = FALSE)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}