POV-Ray : Newsgroups : povray.beta-test : POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10 Server Time
22 Dec 2024 15:56:10 EST (-0500)
  POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10 (Message 1 to 10 of 36)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Thomas de Groot
Subject: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 03:45:46
Message: <60fd16aa$1@news.povray.org>
I am currently testing a macro by jr.: tabulated.inc. In one of his demo 
scenes he uses the following line:

#declare seed_ = val(datetime(now,"%s"));

Using Windows10, and POV-Ray v3.8.0-beta 1, I get the following error:

Parse Error: Invalid formatting code in format string, or resulting 
string too long.

I contacted jr. about this and he answered the following:

"POV-Ray's documentation says the "..optional STRING parameter should
conform to the same formatting as that of the strftime() C function."
and (lowercase) "%s" is documented as described and used.  I assume
that the Windows 'strftime()' does not provide that option?  else it
would be a POV-Ray on Windows bug, I guess."

I mention this error also on behalf of jr. I am not sure about which 
system jr. uses, obviously not Windows, but he will jump in if you need 
to know.

-- 
Thomas


Post a reply to this message

From: jr
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 04:35:00
Message: <web.60fd21d7e398ba995e0fed26cde94f1@news.povray.org>
hi,

Thomas de Groot <tho### [at] degrootorg> wrote:

(thanks, could not post this as I have no MS Windows machine)


> #declare seed_ = val(datetime(now,"%s"));

just to confirm, this works on all Linux systems I have access to, incl a Debian
VM with (oldest) POV-Ray-3.7.0.8.


regards, jr.


Post a reply to this message

From: kurtz le pirate
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 06:18:07
Message: <60fd3a5f$1@news.povray.org>
On 25/07/2021 10:33, jr wrote:

> just to confirm, this works on all Linux systems I have access to, incl a Debian
> VM with (oldest) POV-Ray-3.7.0.8.

Ok on Mac.


#declare DateString = datetime(now,"%s");
#debug concat("DateString     = ",DateString,"\n")

#declare DateNum = val(datetime(now,"%s"));
#debug concat("DateNum        = ",str(DateNum,0,0),"\n")

#declare LongDateString = datetime(now,"%A %e %B %Y %H:%M:%S");
#debug concat("LongDateString = ", LongDateString,"\n")


Result :

DateString     = 1627201022
DateNum        = 1627201022
LongDateString = Sunday 25 July 2021 10:17:02



-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: clipka
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 08:44:15
Message: <60fd5c9f$1@news.povray.org>
Am 25.07.2021 um 09:45 schrieb Thomas de Groot:

> #declare seed_ = val(datetime(now,"%s"));

> "POV-Ray's documentation says the "..optional STRING parameter should
> conform to the same formatting as that of the strftime() C function."
> and (lowercase) "%s" is documented as described and used.  I assume
> that the Windows 'strftime()' does not provide that option?  else it
> would be a POV-Ray on Windows bug, I guess."

 From the Linux man page on die.net (https://linux.die.net/man/3/strftime):
--------------------------------------------------------------
%s

The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). 
(TZ)
--------------------------------------------------------------

For information on what "(TZ)" means, see further on that page:

--------------------------------------------------------------
Conforming To

SVr4, C89, C99. There are strict inclusions between the set of 
conversions given in ANSI C (unmarked), those given in the Single UNIX 
Specification (marked SU), those given in Olson's timezone package 
(marked TZ), and those given in glibc (marked GNU), except that %+ is 
not supported in glibc2. On the other hand glibc2 has several more 
extensions. POSIX.1 only refers to ANSI C; POSIX.2 describes under 
date(1) several extensions that could apply to strftime() as well. The 
%F conversion is in C99 and POSIX.1-2001.
--------------------------------------------------------------

For a list of values officially supported by standard C/C++, see 
https://en.cppreference.com/w/c/chrono/strftime.


TL;DR:

"%s" is a non-standard extension to the `strftime` format, that is not 
universally supported.


Also note that in POV-Ray, `now` already is a numeric value (albeit in 
days, and with 0 corresponding to 2000-1-1, 00:00:00 am UTC). It should 
be trivial to convert to a Unix timestamp without the use of `datetime` 
and `val`, using simple scalar math.


Post a reply to this message

From: jr
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 09:30:00
Message: <web.60fd670de398ba995e0fed26cde94f1@news.povray.org>
hi,

clipka <ano### [at] anonymousorg> wrote:
> Am 25.07.2021 um 09:45 schrieb Thomas de Groot:
>
> > #declare seed_ = val(datetime(now,"%s"));
> ...
> Conforming To
>
> SVr4, C89, C99. ...
> TL;DR:
>
> "%s" is a non-standard extension to the `strftime` format, that is not
> universally supported.

do you have a reference for the "non-standard", please?  cannot see a mention on
the pages I looked at, including
<https://man7.org/linux/man-pages/man3/strftime.3.html>.


regards, jr.


Post a reply to this message

From: clipka
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 17:23:38
Message: <60fdd65a$1@news.povray.org>
Am 25.07.2021 um 15:28 schrieb jr:

> do you have a reference for the "non-standard", please?  cannot see a mention on
> the pages I looked at, including
> <https://man7.org/linux/man-pages/man3/strftime.3.html>.

(1)

The official reference for the fact that it's non-standard would be the 
official documentation of the C and C++ standards: ISO/IEC 9899 and 
ISO/IEC 14882, respectively, in whatever revision of the language you're 
looking at. Of those, the C documentation is the more interesting, as 
the C++ standard only defines it by reference.

The non-standard status of "%s" is documented in ISO-IEC 9899 by 
absence: It is not mentioned, therefore it is non-standard.

I do not have access to an authoritative copy of any revision of ISO/IEC 
9899 aside a PDF copy of good old ANS/ISO 9899-1990, but there the 
relevant information would be found on page 174, in section 7.12.3.5, 
"The strftime function"

For ISO/IEC 9899:1999, that forms the main basis for C++, I only have 
access to drafts (access to authoritative ISO/IEC standard documents 
requires a license fee). In a PDF titled "ISO/IEC Committee Draft - May 
6, 2005 ISO/IEC 9899:TCs" (which to the best of my knowledge differs 
from ISO/IEC 9899:1999 only in "bugfixes"), the relevant information 
would be found on page 7.23.3.5, "Tthe strftime function".

In the official ANSI PDF release of ISO/IEC 14882:2011(E), the relevant 
information can be found on page 619, section 20.11.8 [date.time] "Date 
and time functions", but it only references the C standard. (The 
footnote explicitly listing conversion specifies from C seems to be 
intended to only explicitly affirm that C++11 supports those specifiers 
added in C99, rather than the smaller set in C89.)


(2)

The page I've linked to, "cppreference.com", is dedicated to faithfully 
documenting the official standard in a more accessible format, and has 
proven quite reliable in being true to the standards and their versions.

The page you're citing documents what is implemented in Linux' glibc. It 
is not authoritative about what to expect from `strftime` on a 100% pure 
standard-conformant system.


(3)

The page you liked to, under "%s", also lists effectively the same 
information as the other man page source I cited:

--------------------------------------------------------------
%s     The number of seconds since the Epoch, 1970-01-01 00:00:00
               +0000 (UTC). (TZ) (Calculated from mktime(tm).)
--------------------------------------------------------------

Again, note the "(TZ)" here. In the section titled "CONFORMING TO", it 
also explains what this "(TZ)" marker means, again just like the man 
page source I cited:

--------------------------------------------------------------

        SVr4, C89, C99.  There are strict inclusions between the set of
        conversions given in ANSI C (unmarked), those given in the Single
        UNIX Specification (marked SU), those given in Olson's timezone
        package (marked TZ), and those given in glibc (marked GNU),
        except that %+ is not supported in glibc2.  On the other hand
        glibc2 has several more extensions.  POSIX.1 only refers to ANSI
        C; POSIX.2 describes under date(1) several extensions that could
        apply to strftime() as well.  The %F conversion is in C99 and
        POSIX.1-2001.

--------------------------------------------------------------

In other words:
- If it is marked "(GNU)", it is supported by glibc.
- If it is marked "(TZ)", it is supported by glibc and "Olson's timezone 
package"
- If it is marked "(SU)", it is supported by glibc and "Olson's timezone 
package", and standardized for Unix in the Single UNIX Specification.
- If it is unmarked, it is supported by glibc and "Olson's timezone 
package", and standardized for Unix in the Single UNIX Specification and 
ANSI C (which in this case appears to mean ANSI-standard C in general, 
not specifically C89 as would usually be the case. ).


(4)

It may be worth noting that Linux' strftime is _not_ in violation of the 
C (and, by extension, C++) standard, which explicitly states: "If a 
conversion specilier is not one of the above. the behavior is 
undefined." In other words, "%s" may crash the program, produce "F*** 
you" as output, or convert the time to a decimal rendition of the number 
of seconds between the very start of 1970 and the specified time. Any of 
these behaviors are acceptable per the C/C++ standard.


Post a reply to this message

From: clipka
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 17:27:37
Message: <60fdd749$1@news.povray.org>
Am 25.07.2021 um 23:23 schrieb clipka:

> For ISO/IEC 9899:1999, that forms the main basis for C++, I only have 

That was supposed to read "... the main basis for C++11". Which is the 
minimum language revision required to build POV-Ray v3.8.

(In POV-Ray v3.7, which requires C++99 as the minimum language version, 
the earlier C89 standard would apply, which is even more limited.)


Post a reply to this message

From: clipka
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 25 Jul 2021 18:00:58
Message: <60fddf1a$1@news.povray.org>
It might be worth weaving the following information into the 
documentation of our "datetime" function:

-------------------------

Which codes are supported depends on the platform POV-Ray is compiled 
an/or running on.

In POV-Ray v3.7, the following codes can be expexted to work reliably:

a,A,b,B,c,d,H,I,j,m,M,p,S,U,w,W,x,X,y,Y,Z,%

In POV-Ray v3.8, the following additional codes can be expexted to work 
reliably:

a,A,b,B,c,C,d,D,e,F,g,G,h,H,I,j,m,M,n,p,r,R,S,t,T,u,U,V,w,W,x,X,y,Y,z,Z,%

-------------------------

(Side note: The C99/C++11 standards define additional two-letter codes 
starting with E or O; while those should also work in POV-Ray v3.8, 
their result _will_ differ between systems, depending on the language 
settings of the computer.


(Also, note to self and fellow developers: It may be worth adding a 
check in POV-Ray itself, to verify whether the formatting string 
submitted is actually portable across platforms, and warn if it isn't.)


Post a reply to this message

From: jr
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 26 Jul 2021 04:40:00
Message: <web.60fe73a3e398ba995e0fed26cde94f1@news.povray.org>
hi,

clipka <ano### [at] anonymousorg> wrote:

I thank you for the (detailed) clarification re status of "%s" (and yr time).  I
dug up a PDF (N1256, Committee Draft 7.9.2007) and was shocked (sort of) to find
no mention of "%s".

and also a big thank you for writing "..in POV-Ray, `now` already is a numeric
value..", this has cleared up a complete misunderstanding.  the documentation
says 'now' is a "keyword" and only illustrates its use in a 'datetime()' call.
I had not realised that 'now' can be used outside 'datetime()'.  :-)  so the
demo scene TdG mentioned simply needs a (fairly) reliable unique seed for the
RNG, whenever it's rendered.  made a couple of quick tests with 'now', and am
thinking of using something like the following to replace the
'datetime(now,"%s")', and would appreciate comment(s):

#declare seed_ = mod((now-int(now))*1e16,1e9);


> It might be worth weaving the following information into the
> documentation of our "datetime" function:

and perhaps improve description of 'now'.


regards, jr.


Post a reply to this message

From: Cousin Ricky
Subject: Re: POV-Ray v3.8.0-beta 1 - Parse error using "%s" in Win10
Date: 26 Jul 2021 10:54:21
Message: <60fecc9d$1@news.povray.org>
On 2021-07-26 4:34 AM (-4), jr wrote:
> 
> and perhaps improve description of 'now'.

The 'now' keyword is documented in the float built-in variables section
of the 3.8 reference manual (as it should be), but unlike most of the
other variables in that section, the word 'now' is not its own header,
so it is easy to miss.  (The same is true of the 'version' keyword.)

The documentation of 'datetime' could use a cross reference to the 'now'
description.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.