SC <date> and milliseconds?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

SC <date> and milliseconds?

Post by Filehero »

Hi,

what's the proper syntax to get a time including milliseconds for further processing with datediff?

Code: Select all

<date YYYY-MM-DD hh:nn:ss###>
                         ^^^
Thanks, FH

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: SC <date> and milliseconds?

Post by jupe »

Here is a post I found useful about date variables, according to it is "ffffff" eg. <date YYYY-MM-DD hh:nn:ssffffff>

viewtopic.php?f=3&t=14299
Last edited by jupe on 07 Jan 2018 11:20, edited 1 time in total.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC <date> and milliseconds?

Post by Filehero »

Hi jupe,

thanks. :D Sometimes the forum search is ..... :twisted:

Seems there's only direct support for microseconds but not milliseconds, but that's ok.

admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC <date> and milliseconds?

Post by admin »

Sure you can show milliseconds:

Code: Select all

echo "<date hh:nn:ss.fff>";

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC <date> and milliseconds?

Post by Filehero »

Why do I get an error for datediff with the second code block?

Code: Select all

  $start = <date YYYY-MM-DD hh:nn:ss>;
  wait(1000);
  $stop = <date YYYY-MM-DD hh:nn:ss>;
  $runtime = datediff($start, $stop, "ms");
  msg($runtime);  

  $start = <date YYYY-MM-DD hh:nn:ss.fff>;
  wait(1000);
  $stop = <date YYYY-MM-DD hh:nn:ss.fff>;
  $runtime = datediff($start, $stop, "ms");
  msg($runtime);

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: SC <date> and milliseconds?

Post by jupe »

I am no expert, so sorry if I am out of line here but for some reason I have found that date needs quoting when you use .fff so this works instead:

Code: Select all

  $start = "<date YYYY-MM-DD hh:nn:ss.fff>";
  wait(1000);
  $stop = "<date YYYY-MM-DD hh:nn:ss.fff>";
  $runtime = datediff($start, $stop, "ms");
  msg($runtime);

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: SC <date> and milliseconds?

Post by highend »

date needs quoting when you use .fff
Correct

I'd call that a bug :ninja:
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC <date> and milliseconds?

Post by admin »

It's because of the dot. Without quoting it is interpreted as concatenator.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC <date> and milliseconds?

Post by Filehero »

Adding quotes was the only thing I didn't try, always thinking my date literal was wonky. Maybe my brain is starting to take off on Sunday as well.

Thanks to everybody.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC <date> and milliseconds?

Post by Filehero »

Don, could you fix this?

Peter's file property script is also evoking this error, so I think it is a regression.

Thanks, FH

admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC <date> and milliseconds?

Post by admin »

Not a bug, but a syntax error. See change log:

Code: Select all

v16.90.0103 - 2016-06-07 23:35
    > Scripting: Since the change in order of operator precedence in v16.80.0006 
      (2016-05-25 13:35), XY native variables with dots cannot be used unquoted 
      anymore because the dots are now seen as concatenators. For example, this 
      line will lead to a syntax error:
        echo <prop #audio.bitrate>;
      You have to do one of these to make it work:
        echo <prop "#audio.bitrate">;
        echo "<prop #audio.bitrate>";

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: SC <date> and milliseconds?

Post by highend »

Why not introduce an exception that doesn't parse them inside

Code: Select all

<...>
variables?
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC <date> and milliseconds?

Post by admin »

Precedence is precedence. There shouldn't be exceptions at such a basic level.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: SC <date> and milliseconds?

Post by Filehero »

admin wrote:Not a bug, but a syntax error. See change log:
Fair enough.

Though I never considered the „<>“ around the XX native variables to be operators but rather special quotes.

admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC <date> and milliseconds?

Post by admin »

Many years ago I allowed them to be used unquoted, I think that was jacky's wish. Maybe shouldn't have done that. One exception leads the next...

... but I have to admit I got used it myself and was surprised that

Code: Select all

echo <date hh:nn:ss.fff>;
doesn't work without quoting. After releasing 18.60.0100 I will try to improve the situation...

Post Reply