stri_datetime_format(time, format = "uuuu-MM-dd HH:mm:ss", tz = NULL,
locale = NULL)stri_datetime_parse(str, format = "uuuu-MM-dd HH:mm:ss", lenient = FALSE,
tz = NULL, locale = NULL)
POSIXct
or an object coercible tostri_datetime_fstr
NULL
or ""
for the default time zone
or a single string with a timezone identifier,
see stri_timezone_list
NULL
or ""
for default locale,
or a single string with locale identifier; a non-Gregorian calendar
may be specified by setting the @calendar=name
keywordstri_datetime_format
returns a character vector.stri_datetime_parse
returns an object of class POSIXct
.
time
or str
.By default, stri_datetime_format
(unlike format.POSIXst
)
formats a date/time object using the current default time zone.
This is for the sake of compatibility with the strftime
function.
format
may be one of DT_STYLE
or DT_relative_STYLE
,
where DT
is equal to date
, time
, or datetime
,
and STYLE
is equal to full
, long
, medium
, or short
.
This gives a locale-dependent date and/or time format.
Note that currently relative
time
formats,
so this flag is currently ignored in such a context.
Otherwise, format
is a pattern:
a string, where specific sequences of characters are replaced
with date and time data from a calendar when formatting or used
to generate data for a calendar when parsing.
For example, y
stands for the year. Characters
may be used multiple times. For instance, if y
is used for the year,
yy
might produce 99
, whereas yyyy
produces 1999
.
For most numerical fields, the number of characters specifies
the field width. For example, if h
is the hour, h
might
produce 5
, but hh
produces 05
.
For some characters, the count specifies whether an abbreviated
or full form should be used, but may have other choices, as given below.
Two single quotes represent a literal single quote, either
inside or outside single quotes. Text within single quotes
is not interpreted in any way (except for two adjacent single quotes).
Otherwise all ASCII letter from a
to z
and A
to Z
are reserved as syntax characters, and require quoting if
they are to represent literal characters. In addition, certain
ASCII punctuation characters may become variable in the future
(eg :
being interpreted as the time separator and /
as a date separator, and replaced by respective
locale-sensitive characters in display).
Note that any characters in the pattern that are not in the ranges
of [a-z]
and [A-Z]
will be treated as quoted text.
For instance, characters like :
, .
, (a space),
#
and @
will appear in the resulting time text
even they are not enclosed within single quotes. The single quote is used
to ``escape'' letters. Two single quotes in a row,
inside or outside a quoted sequence, represent a ``real'' single quote.
Here are some examples:
stri_datetime_add
,
stri_datetime_add<-
;
stri_datetime_create
;
stri_datetime_fields
;
stri_datetime_fstr
;
stri_datetime_now
;
stri_datetime_symbols
;
stri_timezone_get
,
stri_timezone_set
;
stri_timezone_info
;
stri_timezone_list
stri_datetime_parse(c("2015-02-28", "2015-02-29"), "yyyy-MM-dd")
stri_datetime_parse(c("2015-02-28", "2015-02-29"), "yyyy-MM-dd", lenient=TRUE)
stri_datetime_parse("19 lipca 2015", "date_long", locale="pl_PL")
stri_datetime_format(stri_datetime_now(), "datetime_relative_medium")
Run the code above in your browser using DataLab