From frederik at ofb.net  Wed Jan 11 03:58:57 2017
From: frederik at ofb.net (frederik at ofb.net)
Date: Tue, 10 Jan 2017 18:58:57 -0800
Subject: [Rd] bug with strptime, %OS, and "."
In-Reply-To: <22645.38081.776727.305032@max.nulle.part>
References: <20170111014855.GI29294@ofb.net>
	<22645.38081.776727.305032@max.nulle.part>
Message-ID: <20170111025857.GJ29294@ofb.net>

On Tue, Jan 10, 2017 at 08:13:21PM -0600, Dirk Eddelbuettel wrote:
> 
> 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>

For my application I wanted to be able to accept both formats,
"14.mp3" and "14.01234.mp3". Since "14" and "14.01234" both parse as
numbers, I thought "%OS" should accept both.

Yes, I can work around it fairly easily.

Frederick



[Rd] bug with strptime, %OS, and "."
frederik at ofb.net