diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index e195c2a5b7..8318260698 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -75,8 +75,9 @@ class ConditionEditor(QWidget): # {{{ ), 'datetime' : ( (_('is equal to'), 'eq'), - (_('is less than'), 'lt'), - (_('is greater than'), 'gt'), + (_('is earlier than'), 'lt'), + (_('is later than'), 'gt'), + (_('is today'), 'is today'), (_('is set'), 'is set'), (_('is not set'), 'is not set'), (_('is more days ago than'), 'older count days'), @@ -199,6 +200,8 @@ class ConditionEditor(QWidget): # {{{ @property def current_val(self): ans = str(self.value_box.text()).strip() + if not self.value_box.isEnabled(): + ans = '' if self.current_col == 'languages': rmap = {lower(v):k for k, v in iteritems(lang_map())} ans = rmap.get(lower(ans), ans) @@ -310,8 +313,7 @@ class ConditionEditor(QWidget): # {{{ tt += '\n' + _('You can match multiple values by separating' ' them with %s')%m['is_multiple']['ui_to_list'] self.value_box.setToolTip(tt) - if action in ('is set', 'is not set', 'is true', 'is false', - 'is undefined'): + if action in ('is set', 'is not set', 'is true', 'is false', 'is undefined', 'is today'): self.value_box.setEnabled(False) # }}} diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index 514f2dd7b1..884da6cf35 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -6,6 +6,7 @@ import json import re from textwrap import dedent +from calibre.utils.date import format_date, now from polyglot.binary import as_hex_unicode, from_hex_bytes color_row_key = '*row' @@ -178,6 +179,9 @@ class Rule: # {{{ return ("test(field('%s'), '1', '')"%(col)) if action == 'is not set': return ("test(field('%s'), '', '1')"%(col)) + if action == 'is today': + today = format_date(now(), 'yyyy-MM-dd') + return f"strcmp(format_date(raw_field('{col}'), 'yyyy-MM-dd'), '{today}', '', '1', '')" lt, eq, gt = { 'eq': ('', '1', ''), 'lt': ('1', '', ''),