% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/timeStamp.R
\name{timeStamp}
\alias{timeStamp}
\title{Create character timestamps}
\usage{
timeStamp(datetime = NULL, timezone = NULL, unit = "sec", style = "ymdhms")
}
\arguments{
\item{datetime}{Vector of character, integer, or \code{POSIXct} datetimes.}

\item{timezone}{Olson timezone used to interpret incoming datetimes.}

\item{unit}{Temporal precision of the generated timestamp.}

\item{style}{Output timestamp style.}
}
\value{
Character vector of timestamps.
}
\description{
Convert datetimes to compact character timestamps suitable for file names,
identifiers, labels, and other reproducible text output.
}
\details{
Input values are converted with \code{\link[=parseDatetime]{parseDatetime()}} using the required
\code{timezone} argument. When \code{datetime = NULL}, the current UTC time is used
and \code{timezone} defaults to \code{"UTC"}.

The \code{unit} argument controls the precision of the output timestamp. The
\code{style} argument controls the output format.

Supported \code{unit} values are:

\preformatted{
"year"
"month"
"day"
"hour"
"min"
"sec"
"msec"
}

Supported \code{style} values are:

\preformatted{
"ymdhms"   compact calendar time
"ymdThms"  compact calendar time with "T" separator
"julian"   year and Julian day
"clock"    ISO-like clock time
}

For \code{style = "julian"} and \code{unit = "month"}, the timestamp uses the Julian
day associated with the beginning of the month.
}
\section{POSIXct inputs}{

When \code{startdate} or \code{enddate} are already \code{POSIXct} values, they are first
converted to \code{timezone} with \code{\link[lubridate:with_tz]{lubridate::with_tz()}} without changing the
represented instant in time.
}

\examples{
datetime <- parseDatetime("2019-01-08 12:30:15", timezone = "UTC")

timeStamp()
timeStamp(datetime, "UTC", unit = "year")
timeStamp(datetime, "UTC", unit = "month")
timeStamp(datetime, "UTC", unit = "month", style = "julian")
timeStamp(datetime, "UTC", unit = "day")
timeStamp(datetime, "UTC", unit = "day", style = "julian")
timeStamp(datetime, "UTC", unit = "hour")
timeStamp(datetime, "UTC", unit = "min")
timeStamp(datetime, "UTC", unit = "sec")
timeStamp(datetime, "UTC", unit = "sec", style = "ymdThms")
timeStamp(datetime, "UTC", unit = "sec", style = "julian")
timeStamp(datetime, "UTC", unit = "sec", style = "clock")
timeStamp(datetime, "America/Los_Angeles", unit = "sec", style = "clock")
timeStamp(datetime, "America/Los_Angeles", unit = "msec", style = "clock")

}
