How to filter all events with precise dates?

Gramps 5.1 Win 10 x64

I’d like to separate/filter out events with precise dates from events with not-precise dates (such as “after 1811” or “between x and y”).

I’ve tried to create a filter to no avail. I’ve found a rule that allows me for example to show all events that contain certain date information (for example everything “after 1811”) but that also includes uncertain dates. I’ve tried entering regex at the specific rule (in the date field) but I can’t get that to work.

Any ideas? Greatly appreciate any help.

There is an Isotammi addon filter rule for Invalid dates. But there isn’t a Filter Rule that tests the “Quality” or “Modifier” for a date vale.

You could create a SuperTool query for those attributes. Then save that Query as a Custom Filter.

If you are more ambitious, you could modify the Isotammi addon rule to test the Quality and Modifier.

Thank you for your reply. Regrettably I’m far too unfamiliar with programming and Python to effectively use SuperTool :frowning:

This is not an answer… just posting some musings while considering the problem. (Have to do something else and don’t want to lose the line of thought.)

I looks like a filter would have to be a bit more technical than most users will be willing to use.

In the Gramps data model, dates are represented as:
image
Some of these are described in the wiki. (Things like: dateval, sortval, and text are described in the DateBase developer documentation.)

It looks like you’re looking for a rule built around is_regular()

As you discovered, filtering and dates causes you to pull hair out.

Try this…

Go to the Events view.
Close the Sidebar Filter. menu >> View >> Sidebar

This brings up a filter by the columns. (at the top of the view) Change to Date contains. Enter “about” (no quotes) for the filter, then Find.

Once the results are returned then the best thing to do is to select all, and then Tag. the entries.

Repeat for “from” and “between”.

The advantage is this view filter (all list views have this type of filter) is that it is a literal filter of the column entries.

Once the events are tagged, it becomes easier to add or exclude them from custom filters.

Ok, here are 2 custom filters generated by SuperTool scripts. (And you have to have the SuperTool addon installed because it provides functionality that might be needed for the Custom Filters. Such as custom properties shortcuts that you might have used in the Script.) If you don’t want to install the Custom Filters using the scripts, you can paste the filter definition into the custom_filters.xml file. (As described in “Sharing custom filters”.)

  • SuperTool_IrregularDates - Finds Events with inexact dates
  • SuperTool_RegularDates - Find Events with complete dates - validated with a day, month and year. (No spans or ranges)

In Gramps User Directory’s Gramps51 folder, custom_filters.xml

<?xml version="1.0" encoding="utf-8"?>
<filters>
  <object type="Event">
    <filter name="SuperTool_RegularDates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="dateobject.is_regular()"/>
        <arg value="#  Return &quot;True&quot; if the date is a regular date.&lt;br&gt;#  The regular date is a single exact date, i.e. not text-only, not a range or a span, &lt;br&gt;#    not estimated/calculated, not about/before/after date, and having  a year, &lt;br&gt;#    month, and day all non-zero.&lt;br&gt;# see   https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
    <filter name="SuperTool_IrregularDates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="not (event.get_date_object().is_regular() or event.get_date_object().is_empty())"/>
        <arg value="# Return True if matches events having a irregular date but not a blank date)<br># see https://gramps-project.org/docs/gen/gen_lib.html#gramps.gen.lib.date.Date.is_regular"/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
    <filter name="SuperTool_Blank_Dates" function="and">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="event.get_date_object().is_empty()"/>
        <arg value="#  Return &quot;True&quot; if the date is a blank date."/>
        <arg value="dateobject=self.event.get_date_object()"/>
      </rule>
    </filter>
  </object>
</filters>

Or… if you’re up to trying to see how these were built, here’s the initial script where you can “File → Open” and “File → Save as filter” when in SuperTool with the Events category active. This creates the 1st Custom Filter in the Events category using the text in the Title field:

[Gramps SuperTool_beta script file]
version=1
[title]
SuperTool_IrregularDates
[category]
Events
[initial_statements]
#  Return "True" if the date is a regular date.
#  The regular date is a single exact date, i.e. not text-only, not a range or a span, not estimated/calculated, 
#    not about/before/after date, and having year, month, and day all non-zero.
# see   https://gramps-project.org/docs/gen/gen_lib.html?highlight=is_regular#gramps.gen.lib.date.Date.is_regular
[statements]
dateobject=self.event.get_date_object()
[filter]
not dateobject.is_regular()
[expressions]
type, date, placename, participants, dateobject.is_regular(), description
[scope]
selected
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False

To create the 2nd Custom Filter, just change the name in the Title (from Irregular to Regular) and eliminate the "not " at the beginning of the Filter field. Then Save as filter again.

Thank you both very much @DaveSch and @emyoulation !

I was unaware of the filter by columns option you get when disabling the sidebar (because I never closed it…), this will definitely come in handy in the future.

I managed to get the scripts saved as filters and they’re just perfect. This saves me a lot of trouble and while I hope that it wasn’t too much effort from your side it is greatly appreciated all the same. It’s also insightful to me as to how this works, perhaps one day I’ll be able to learn to do this myself.

1 Like

Actually, it was a good push. I’ve been procrastinating about learning SuperTool’s filter feature. (There so many other possibilities!) Now I have fodder for writing a tutorial.

Including taking the scripts to the next level: converting the scripts to Rule addons that are totally independent of SuperTool. Trying now to figure how to change the GUI so it can go from 5 rules to a single rule with options.