Skip to content

format.POSIXlt drops characters following percent sign (PR#8975)

2 messages · Jeffrey J. Hallman, Brian Ripley

#
Full_Name: Jeff Hallman
Version: 2.3.1
OS: Windows
Submission from: (NULL) (132.200.32.34)


Internal(format.POSIXlt(as.POSIXlt(Sys.time()), "%Y%m%d%q", F)) 
      Linux R-2.2.1 returns "20060613%q".
    Windows R-2.3.1 returns "20060613" dropping the "%q".  

The documentation says "Any character in the format string other that the '%'
escape sequences is interpreted literally".  Since "%q" is nowhere listed as an
escape sequence, the Windows R-2.3.1 result appears to be incorrect.

The Unix 'date' command gives the same result as Linux R-2.2.1.
#
On Tue, 13 Jun 2006, jhallman at frb.gov wrote:

            
There is no such command as Internal: you seem to be mean .Internal but 
please use user-level functions.
What the help page actually says is (no typo):

      The details of the formats are system-specific, but the following
      are defined by the ISO C / POSIX standard for 'strftime' and are
      likely to be widely available.  Any character in the format string
      other than the '%' escape sequences is interpreted literally (and
      '%%' gives '%').

The help page carefully does not say what *any* escape sequence does, nor 
what the escape sequences are: it merely indicates common behaviour.
It seems you did not look up what the standards say, which is

   If a conversion specification does not correspond to any of the above,
   the behavior is undefined.

And `undefined' is itself defined in the standards.  The Windows 
documentation does not say what it does (nor does the glibc 
documentation), not even that it is system-specific.  In fact the MSDN 
docs for strftime say

   Characters that do not begin with % are copied unchanged to strDest.

(Make of that what you can.)

Where standards are referred to, please do consult them.  The kind people 
who develop R have even provided links to them at
http://developer.r-project.org/Portability.html