rejetto forum

urlvars new proposal: timeFiltered (WAITING ACCEPT FROM THE BOSS)

Mars · 4 · 6720

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
Quote
....
  end; // allowedTo

  function timeFiltered(filetime: Tdatetime):boolean;       //mars time good
  var
    older, newer, curtime: Tdatetime;
  begin
  curtime:=now();
  if not TryStrToDate(data.urlvars.Values['older'], older) then
    older:=incDay(curtime,-strtointdef(data.urlvars.Values['older'],-1));
  if not TryStrToDate(data.urlvars.Values['newer'], newer) then
    newer:=incDay(curtime,-strtointdef(data.urlvars.Values['newer'],integer(trunc(curtime))));
  result:=if_(newer <= older,(newer <= filetime) and (filetime <= older),(filetime < older)or(newer < filetime));
  end;


  procedure includeFilesFromDisk();
  var
.....

  procedure includeFilesFromDisk();
......
   // we don't list these entries
        if (sr.name = '.') or (sr.name = '..')
        or isCommentFile(sr.name) or isFingerprintFile(sr.name) or sameText(sr.name, DIFF_TPL_FILE)
        or not hasRightAttributes(sr.attr)
        or stringExists(sr.name, namesInVFS)
        or not timefiltered(filedateToDatetime(sr.Time))      //mars time good
        then continue;

        filteredOut:=not fileMatch( if_(sr.Attr and faDirectory > 0, foldersFilter, filesFilter), sr.name)
          or not fileMatch( if_(sr.Attr and faDirectory > 0, urlFoldersFilter, urlFilesFilter), sr.name);
        // if it's a folder, though it was filtered, we need to recur 
.....
  end; // includeFilesFromDisk
......

  procedure includeItemsFromVFS();
......
    // filtered out
    if not fileMatch( if_(f.isFolder(), foldersfilter, filesfilter), f.name)
    or not fileMatch( if_(f.isFolder(), urlFoldersfilter, urlFilesfilter), f.name)
    or not timefiltered(f.mtime)  //mars time good
     then
      begin
      if recursive then recurOn(f);
      continue;
      end;
....

two new urlvars:    newer and older     ( than a date or number of days)

usage examples:
   files newest since a date to now             ?sort=d&reverse&newer=22/02/2009
   files newest since a few days to now       ?sort=d&reverse&newer=20

   files oldest that a date                          ?sort=d&reverse&older=01/03/2009
   files oldest since a few days before now   ?sort=d&reverse&older=15

files between two dates or days
                  ?sort=d&reverse&newer=20&older=15
                  ?sort=d&reverse&newer=22/02/2009&older=01/03/2009
                  ?sort=d&reverse&newer=20&older=01/03/2009
                  ?sort=d&reverse&newer=22/02/2009&older=15


only files since never=22/02/2009 to older=01/03/2009

files outside two dates or days
    we have to invert values of dates never=01/03/2009 and older=22/02/2009
     files are those from 01/01/1889 to  oldest than older=22/02/2009  + from newest never=01/03/2009 to now

             ?sort=d&reverse&older=22/02/2009&newer=01/03/2009
             ?sort=d&reverse&older=20&newer=15
             ?sort=d&reverse&older=22/02/2009&newer=15
             ?sort=d&reverse&older=20&newer=01/03/2009

« Last Edit: April 11, 2009, 03:58:23 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
this can already be done with macros

{.if|{. {.calc|%now% - %item-modified-dt%.} <= %newer% .}|
show the file
.}


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
%newer% ???? not found in source

%new% exists but is defined with regard to date fixed beforehand in hfs,
If the user wishes to use the url to select only files between two dates, it is not possible with macro, the macro are banned in the url.

What I proposed, they are supplementary urlvars but not macro, their use can be interesting for a custom in a form including a targeted searc  which does not require macro.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
Quote
%newer% ???? not found in source

sorry for not being clear: i meant the value you named "newer".
if you want to read it from the url, clearly you will use {.?newer.}
it was not meant to work, it was to show that it can be done easily with macros.

Quote
What I proposed, they are supplementary urlvars but not macro, their use can be interesting for a custom in a form including a targeted searc  which does not require macro.

why should we want to do it without macros?