[Rd] bug with strptime, %OS, and "."

Dirk Eddelbuettel edd at debian.org
Wed Jan 11 03:13:21 CET 2017


On 10 January 2017 at 17:48, frederik at ofb.net wrote:
| Hi R Devel,
| 
| I just ran into a corner case with 'strptime'. Recall that the "%OS"
| conversion accepts fractional seconds:
| 
| > strptime("17_35_14.01234.mp3","%H_%M_%OS.mp3")$sec
| [1] 14.01234
| 
| Unfortunately for my application it seems to be "greedy", in that it
| tries to parse a decimal point which might belong to the rest of the
| format:
| 
| > strptime("17_35_14.mp3","%H_%M_%OS.mp3")
| [1] NA

Maybe just don't use the optional O:

   R> strptime("17_35_14.mp3","%H_%M_%S.mp3")$sec
   [1] 14
   R> 
   R> strptime("17_35_14.mp3","%H_%M_%S.mp3")
   [1] "2017-01-10 17:35:14 CST"
   R>
   
Dirk
 
| If I use "_" instead of ".", then it works:
| 
| > strptime("17_35_14_mp3","%H_%M_%OS_mp3")
| [1] "2017-01-10 17:35:14 PST"
| 
| Perhaps a low priority, but seems like a bug to me...
| 
| Thanks,
| 
| Frederick
| 
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-devel mailing list