tidyverse / hms

A simple class for storing time-of-day values
https://hms.tidyverse.org/
Other
138 stars 25 forks source link

Inconsistency between tibble and vector formatting if "hours" component is zero #112

Open markconnolly opened 1 year ago

markconnolly commented 1 year ago

A tibble

library(tidyverse)

paces <- as_tibble_col(c("00:05:07", "00:05:25", "00:05:34",
                         "00:06:20", "00:06:21") %>% 
                         hms::as_hms(), column_name = "pace")
paces
#> # A tibble: 5 x 1
#>   pace  
#>   <time>
#> 1 05'07"
#> 2 05'25"
#> 3 05'34"
#> 4 06'20"
#> 5 06'21"
paces$pace
#> 00:05:07
#> 00:05:25
#> 00:05:34
#> 00:06:20
#> 00:06:21

paces2 <- as_tibble_col(c("01:05:07", "00:05:25", "00:05:34", 
                         "00:06:20", "00:06:21") %>% 
                         hms::as_hms(), column_name = "pace")
paces2
#> # A tibble: 5 x 1
#>   pace    
#>   <time>  
#> 1 01:05:07
#> 2 00:05:25
#> 3 00:05:34
#> 4 00:06:20
#> 5 00:06:21
paces2$pace
#> 01:05:07
#> 00:05:25
#> 00:05:34
#> 00:06:20
#> 00:06:21

Created on 2022-10-26 by the reprex package (v2.0.1)

krlmlr commented 1 year ago

Thanks. The minutes+seconds formatting is desired, but I do wonder why the formatting in a vector is different.