convert_seconds_to_time: Convert seconds after midnight to time strings

View source: R/convert_seconds_to_time.R

convert_seconds_to_timeR Documentation

Convert seconds after midnight to time strings

Description

Converts times in seconds after midnight to strings in the "HH:MM:SS" format, as used in stop_times and frequencies. It is the counterpart of convert_time_to_seconds(), useful to write back times calculated from the ⁠_secs⁠ columns.

Usage

convert_seconds_to_time(seconds)

Arguments

seconds

A numeric vector with whole numbers of seconds after midnight, between 0 and 35999999 ("9999:59:59"). Values within floating-point tolerance of a whole number are rounded. difftime objects are converted to seconds first.

Value

A character vector with the same length as seconds. NAs are converted to "", as blank times in GTFS. Times past midnight keep counting the hours (e.g. "25:30:00"). Names are dropped.

See Also

convert_time_to_seconds()

Examples


convert_seconds_to_time(c(0, 3600, 91800, NA))

data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
gtfs <- convert_time_to_seconds(gtfs, file = "stop_times")

# delay every departure by 5 minutes
delayed_departure <- convert_seconds_to_time(
  gtfs$stop_times$departure_time_secs + 300
)
head(delayed_departure)


gtfstools documentation built on Oct. 28, 2026, 5:13 p.m.