Menu

#6 Still problems with valid times

open
nobody
None
5
2020-11-15
2011-08-01
Anonymous
No

Sorry for being so blunt, but are the problems with stroke rejecting valid times ever going to get fixed?

I run into things like this all the time:

# touch file
# stroke -i file
stroke: file
stroke: mtime: 08/01/2011-06:53:12 Mon (-dst)
stroke: atime: 08/01/2011-06:53:12 Mon (-dst)
stroke: ctime: 08/01/2011-06:53:12 Mon (-dst)
# touch -d '20110731 10:14:30' file
# stroke -i file

stroke: ** ERROR: Date validation failed: "07/31/2011-10:14:30 Sun (-dst)"

There is nothing wrong with that time, but stroke can't work with it.

Related

Bug reports: #6

Discussion

  • Alberto Varesio

    Alberto Varesio - 2020-10-15

    I made this only change to the source and it seems to validate dates better:

    $ LC_ALL=C TZ=UTC0 diff -Naur aux.c.old aux.c
    --- aux.c.old   2020-10-15 16:42:54.085730137 +0000
    +++ aux.c   2020-10-15 16:42:28.405609962 +0000
    @@ -419,7 +419,7 @@
                    goto error;
            }
    
    
    -       if(months >> D(MON) && D(DAY) > 30) {
    +       if(months >> D(MON)  & D(DAY) > 30) {
                goto error;
            } else if(D(MON) == 2) {
                /* leap year */
    

    Checked with

    for D in {1..365}; do TS=$(date -d "20110101 + $D day" '+%Y%m%d 10:12:14'); echo $TS; touch -d "$TS" file ; stat file ; ./stroke -i file ; done
    
     

    Last edit: Alberto Varesio 2020-10-15
  • Sören Wellhöfer

    Hello Albert,

    I don't think your fix is correct. Although it seems to work in your case, just replacing the logical && with a bitwise AND-operator is not the correct fix here in my opinion. The code has some logical issues in my opinion.

    Best regards,
    Sören

     
    • Alberto Varesio

      Alberto Varesio - 2020-11-16

      Hi Sören
      Yes maybe code needs a rewrite, but I remember to have tested it against a
      full year of dates and it looked correct.
      With the logical AND code is testing an integer value ( months shifted by
      the value of D ) which will always result in a > 0 value, which will always
      be considered true, so the second test is ineffective until December.
      With bitwise AND the same value is ANDed with a 0/1 from the second
      condition, so it will get true/false on the right months, hopefully
      Regards

      On Sun, Nov 15, 2020 at 6:01 PM "Sören Wellhöfer" welle@users.sourceforge.net wrote:

      Hello Albert,

      I don't think your fix is correct. Although it seems to work in your case,
      just replacing the logical && with a bitwise AND-operator is not the
      correct fix here in my opinion. The code has some logical issues in my
      opinion.

      Best regards,
      Sören


      ** [bug-reports:#6] Still problems with valid times**

      Status: open
      Group:
      Created: Mon Aug 01, 2011 06:59 AM UTC by Anonymous
      Last Updated: Thu Oct 15, 2020 04:55 PM UTC
      Owner: nobody

      Sorry for being so blunt, but are the problems with stroke rejecting valid
      times ever going to get fixed?

      I run into things like this all the time:

      # touch file
      # stroke -i file
      stroke: file
      stroke: mtime: 08/01/2011-06:53:12 Mon (-dst)
      stroke: atime: 08/01/2011-06:53:12 Mon (-dst)
      stroke: ctime: 08/01/2011-06:53:12 Mon (-dst)
      # touch -d '20110731 10:14:30' file
      # stroke -i file

      stroke: ** ERROR: Date validation failed: "07/31/2011-10:14:30 Sun
      (-dst)"

      There is nothing wrong with that time, but stroke can't work with it.


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/stroke/bug-reports/6/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

      --
      Alberto 'JCN-9000' Varesio
      IT Administrator
      Mobile: +39 393 101 8844
      LI: http://www.linkedin.com/in/albertovaresio

       

      Related

      Bug reports: #6


Log in to post a comment.

MongoDB Logo MongoDB