Skip to content
Prev 55374 / 63424 Next

Bug in as.Date or strptime?

On 22/06/2018 9:55 AM, Rui Barradas wrote:
Since x is numeric, it is added to the origin date.  But the origin date 
is a character, so it is converted to a date using format.  The %j 
format says "day of year"; since you didn't give a year, that is assumed 
to be the current year, 2018.  %j only uses the 1st 3 digits that it 
finds, so the origin is taken to be day 201 of 2018.  Add 1, you get 
July 21.
Since no format is given, the origin is found using the default 
conversion, which gives what you'd expect.  Then we add one day.
Same as above.  Same result, hurray!
There's no problem here.  The format is ignored for numeric x and date 
object origin.  This is the same as 2a.
origin is ignored for character x.  That is day 1 of the default year.
There's no default conversion for '1'.
origin is ignored again, so this is the same as number 4.


Duncan Murdoch