benibela / xidel

Command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern matching. It can also create new or transformed XML/HTML/JSON documents.
http://www.videlibri.de/xidel.html
GNU General Public License v3.0
674 stars 42 forks source link

Incorrect time conversion on androidarm build #81

Closed Baltazar500 closed 2 years ago

Baltazar500 commented 2 years ago

When using the expression

echo '<epg_list code="0"><epg><p><startdate>1639833900</startdate><enddate>1639840500</enddate><name>TvShowName</name></p></epg></epg_list>'|xidel-0.9.9.20211214.8268.ffad46040257.androidarm -se '//epg_list/epg/p/concat(format-dateTime((startdate * duration("PT1S") + dateTime("1970-01-01T00:00:00")), "[H01]:[m01]:[s01]"), " ... ", name)'

on arm build I get

04:00:54 ... TvShowName

instead

13:25:00 ... TvShowName

Problems only on the androidarm build (xidel-0.9.9.20211214.8268.ffad46040257.androidarm). androidarm64 build works correctly. On build xidel-0.9.9.20211123.8232.023d1f1f656e.androidarm the same problem.

Build xidel-0.9.9.20210620.7908.1f19357dcdf2.androidarm works correctly

benibela commented 2 years ago

Run it with --trace to get a step-by-step evaluation where we see which calculation goes wrong

And try startdate * dayTimeDuration("PT1S"). I misunderstood the standard when I implemented duration multiplication. It should not be allowed in XPath, only dayTimeDuration multiplication is valid here

Baltazar500 commented 2 years ago

@benibela,

xidel-0.9.9.20211214.8268.ffad46040257.androidarm

bash-4.4# echo '<epg_list code="0"><epg><p><startdate>1639833900</startdate><enddate>1639840500</enddate><name>TvShowName</name></p></epg></epg_list>'|xidel-0.9.9.20211214.8268.ffad46040257.androidarm --trace -se '//epg_list/epg/p/concat(format-dateTime((startdate * duration("PT1S") + dateTime("1970-01-01T00:00:00")), "[H01]:[m01]:[s01]"), " ... ", name)'
operator *(<startdate>1639833900</startdate>, xs:duration("PT1S"))
operator +(xs:duration("P106751991DT4H54.775807S"), xs:dateTime("1970-01-01T00:00:00"))
Q{http://www.benibela.de/2012/pxp/extensions}format-dateTime(xs:dateTime("294247-01-10T04:00:54.775807"), "[H01]:[m01]:[s01]")
Q{http://www.benibela.de/2012/pxp/extensions}concat("04:00:54", " ... ", <name>TvShowName</name>)
04:00:54 ... TvShowName

xidel-0.9.9.20210620.7908.1f19357dcdf2.androidarm

bash-4.4# echo '<epg_list code="0"><epg><p><startdate>1639833900</startdate><enddate>1639840500</enddate><name>TvShowName</name></p></epg></epg_list>'|xidel-0.9.9.20210620.7908.1f19357dcdf2.androidarm --trace -se '//epg_list/epg/p/concat(format-dateTime((startdate * duration("PT1S") + dateTime("1970-01-01T00:00:00")), "[H01]:[m01]:[s01]"), " ... ", name)'
operator *(<startdate>1639833900</startdate>, xs:duration("PT1S"))
operator +(xs:duration("P18979DT13H25M"), xs:dateTime("1970-01-01T00:00:00"))
Q{http://www.benibela.de/2012/pxp/extensions}format-dateTime(xs:dateTime("2021-12-18T13:25:00"), "[H01]:[m01]:[s01]")
Q{http://www.benibela.de/2012/pxp/extensions}concat("13:25:00", " ... ", <name>TvShowName</name>)
13:25:00 ... TvShowName

xidel-0.9.9.20211214.8268.ffad46040257.androidarm + startdate * dayTimeDuration("PT1S")

bash-4.4# echo '<epg_list code="0"><epg><p><startdate>1639833900</startdate><enddate>1639840500</enddate><name>TvShowName</name></p></epg></epg_list>'|xidel-0.9.9.20211214.8268.ffad46040257.androidarm --trace -se '//epg_list/epg/p/concat(format-dateTime((startdate * dayTimeDuration("PT1S") + dateTime("1970-01-01T00:00:00")), "[H01]:[m01]:[s01]"), " ... ", name)'
operator *(<startdate>1639833900</startdate>, xs:dayTimeDuration("PT1S"))
operator +(xs:dayTimeDuration("P106751991DT4H54.775807S"), xs:dateTime("1970-01-01T00:00:00"))
Q{http://www.benibela.de/2012/pxp/extensions}format-dateTime(xs:dateTime("294247-01-10T04:00:54.775807"), "[H01]:[m01]:[s01]")
Q{http://www.benibela.de/2012/pxp/extensions}concat("04:00:54", " ... ", <name>TvShowName</name>)
04:00:54 ... TvShowName
benibela commented 2 years ago

That might have been happening since I updated to FreePascal 3.2.3

I have reported it here: https://gitlab.com/freepascal.org/fpc/source/-/issues/39490

Baltazar500 commented 2 years ago

That might have been happening since I updated to FreePascal 3.2.3

What is the last build of xidel before the FreePascal update ?

benibela commented 2 years ago

I do not really remember.

The time stamp on the compiler executable is from October, so it is probably xidel-0.9.9.20210818.8090.c8e45f7fe96e

Baltazar500 commented 2 years ago

The time stamp on the compiler executable is from October, so it is probably xidel-0.9.9.20210818.8090.c8e45f7fe96e

Yes, this is that build. Time conversion works correctly. The next build (xidel-0.9.9.20211123.8232.023d1f1f656e.androidarm) shows the time "04:00:54" instead of "13:25:00"

benibela commented 2 years ago

But you should still use the new build, because we need to find these bugs before that FreePascal version becomes the next "stable" release

I could allow duration("PT1639833900S"). I would need to rewrite all the date parsing functions to use 64-bit rather than 32-bit

Baltazar500 commented 2 years ago

But you should still use the new build, because we need to find these bugs before that FreePascal version becomes the next "stable" release

OK. Where can I get a new build for the test ? On sourceforge, in the Xidel development folder, the latest build from 2021.12.14

Reino17 commented 2 years ago

benibela means r8268, the latest development build. And you can find new future builds in the development folder, or compile your own.

Baltazar500 commented 2 years ago

And you can find new future builds in the development folder, or compile your own.

ОК.

-bash-4.4# xidel="/storage/sdcard1/Download/xidel-0.9.9.20211225.8285.b90e197a0a24.androidarm"; echo '<epg_list code="0"><epg><p><startdate>1639833900</startdate><enddate>1639840500</enddate><name>TvShowName</name></p></epg></epg_list>'|$xidel --trace -se '//epg_list/epg/p/concat(format-dateTime((startdate * duration("PT1S") + dateTime("1970-01-01T00:00:00")), "[H01]:[m01]:[s01]"), " ... ", name)'
operator *(<startdate>1639833900</startdate>, xs:duration("PT1S"))
operator +(xs:duration("P106751991DT4H54.775807S"), xs:dateTime("1970-01-01T00:00:00"))
Q{http://www.benibela.de/2012/pxp/extensions}format-dateTime(xs:dateTime("294247-01-10T04:00:54.775807"), "[H01]:[m01]:[s01]")
Q{http://www.benibela.de/2012/pxp/extensions}concat("04:00:54", " ... ", <name>TvShowName</name>)
04:00:54 ... TvShowName
-bash-4.4#
benibela commented 2 years ago

Looks like they had fixed the bug in November, but I was using a version from October

Baltazar500 commented 2 years ago

Yes, the problem is gone :) Thanks.