@@ -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 }
138138object.
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+
140152We 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+
248266as.POSIXct("2001-01-01") + as.ITime("10:45")
249267
250268datetime <- seq(as.POSIXct("2001-01-01"), as.POSIXct("2001-01-03"), by = "5 hour")
0 commit comments