<para>
<emphasis>offset</emphasis> is specified as a positive number with one
-of the units from <xref linkend="tab-date-units"/>.
+of the units from <xref linkend="tab-rel-date-units"/>.
</para>
+<table id="tab-rel-date-units">
+<title>Relative date units</title>
+<tgroup cols="2">
+<thead>
+<row><entry>Unit</entry><entry>Description</entry></row>
+</thead>
+<tbody>
+<row><entry>y</entry><entry>Years</entry></row>
+<row><entry>m</entry><entry>Months</entry></row>
+<row><entry>w</entry><entry>Weeks</entry></row>
+<row><entry>d</entry><entry>Days</entry></row>
+<row><entry>H</entry><entry>Hours</entry></row>
+<row><entry>M</entry><entry>Minutes</entry></row>
+<row><entry>S</entry><entry>Seconds</entry></row>
+</tbody>
+</tgroup>
+</table>
+
<para>
Example: to select messages less than 1 month old, you would use
</para>
case 'd':
tm->tm_mday += offset;
break;
+ case 'H':
+ tm->tm_hour += offset;
+ break;
+ case 'M':
+ tm->tm_min += offset;
+ break;
+ case 'S':
+ tm->tm_sec += offset;
+ break;
default:
return s;
}
static int eval_date_minmax (pattern_t *pat, const char *s, BUFFER *err)
{
struct tm min, max;
+ char *offset_type;
memset (&min, 0, sizeof (min));
/* the `0' time is Jan 1, 1970 UTC, so in order to prevent a negative time
if (s[0] == '=')
exact++;
}
- tm->tm_hour = 23;
- tm->tm_min = tm->tm_sec = 59;
+
+ /* Reset the HMS unless we are relative matching using one of those
+ * offsets. */
+ strtol (s + 1, &offset_type, 0);
+ if (!(*offset_type && strchr ("HMS", *offset_type)))
+ {
+ tm->tm_hour = 23;
+ tm->tm_min = tm->tm_sec = 59;
+ }
/* force negative offset */
get_offset (tm, s + 1, -1);