Skip to content

Commit 103825b

Browse files
committed
added information
1 parent 2642b84 commit 103825b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

man/IDateTime.Rd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ hours. Because \code{ITime} is stored in seconds, you can add it to a
137137
\code{POSIXct} object, but you should not add it to a \code{Date}
138138
object.
139139

140+
141+
\code{ITime} is a time-of-day class stored as the integer number of
142+
seconds in the day. \code{as.ITime} does not allow days longer than 24
143+
hours. Because \code{ITime} is stored in seconds, you can add it to a
144+
\code{POSIXct} object, but you should not add it to a \code{Date}
145+
object.
146+
147+
For \code{as.ITime}, note that the string \code{"24:00:00"} is parsed as \code{"00:00:00"}.
148+
This is because the conversion uses \code{as.POSIXct}, which treats \code{"24:00:00"} as midnight of the next day.
149+
This differs from ISO 8601 (which allows \code{"24:00:00"} to represent end-of-day), but aligns with POSIX standards.
150+
To represent end-of-day intervals, use \code{"23:59:59"} or arithmetic (e.g., \code{as.ITime("23:59:59") + 1L}).
151+
140152
We also provide S3 methods to convert to and from \code{Date} and \code{POSIXct}.
141153

142154
\code{ITime} is time zone-agnostic. When converting \code{ITime} and
@@ -245,6 +257,12 @@ identical(as.ITime("10:45"), methods::as("10:45", "ITime"))
245257
246258
(t <- as.ITime("10:45:04", format = "\%H:\%M:\%S"))
247259
260+
# "24:00:00" is parsed as "00:00:00"
261+
as.ITime("24:00:00")
262+
263+
# Workaround for end-of-day: add 1 second to "23:59:59"
264+
as.ITime("23:59:59") + 1L
265+
248266
as.POSIXct("2001-01-01") + as.ITime("10:45")
249267
250268
datetime <- seq(as.POSIXct("2001-01-01"), as.POSIXct("2001-01-03"), by = "5 hour")

0 commit comments

Comments
 (0)