-
Notifications
You must be signed in to change notification settings - Fork 51
/
README.cond-date
163 lines (112 loc) · 4.41 KB
/
README.cond-date
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
Conditional Dates Patch
=======================
Use rules to choose date format
Patch
-----
To check if Mutt supports "Conditional Dates", look for "patch-cond-date"
in the mutt version.
Dependencies
* mutt-1.5.24
* nested-if patch
Introduction
------------
The "cond-date" patch allows you to construct $index_format expressions
based on the age of the email.
Mutt's default '$index_format' displays email dates in the form:
abbreviated-month day-of-month — "Jan 14".
The format is configurable but only per-mailbox. This patch allows you to
configure the display depending on the age of the email.
Potential Formatting Scheme
| Email Sent | Format | Example |
|-------------------|---------|---------|
| Today | '%H:%M' | 13:23 |
| This Month | '%a %d' | Thu 17 |
| This Year | '%b %d' | Dec 10 |
| Older than 1 Year | '%m/%y' | 06/14 |
For an explanation of the date formatting strings, see 'strftime(3).'
By carefully picking your formats, the dates can remain unambiguous and
compact.
Mutt's conditional format strings have the form: (whitespace introduced for
clarity)
%? TEST ? TRUE & FALSE ?
The examples below use the test "%[" — the date of the message in the local
timezone. They will also work with "%(" — the local time that the message
arrived.
The date tests are of the form:
%[nX? TRUE & FALSE ?
* "n" is an optional count (defaults to 1 if missing)
* "X" is the time period
Date Formatting Codes
| Letter | Time Period |
|--------|-------------|
| y | Years |
| m | Months |
| w | Weeks |
| d | Days |
| H | Hours |
| M | Minutes |
Date Tests
| Test | Meaning |
|--------|----------------------|
| '%[y' | This year |
| '%[1y' | This year |
| '%[6m' | In the last 6 months |
| '%[w' | This week |
| '%[d' | Today |
| '%[4H' | In the last 4 hours |
### Example 1
We start with a one-condition test.
Example 1
| Test | Date Range | Format String | Example |
|--------|------------|---------------|------------|
| '%[1m' | This month | '%[%b %d]' | Dec 10 |
| | Older | '%[%Y-%m-%d]' | 2015-04-23 |
The $index_format string would contain:
%?[1m?%[%b %d]&%[%Y-%m-%d]?
Reparsed a little, for clarity, you can see the test condition and the two
format strings.
%?[1m? & ?
%[%b %d] %[%Y-%m-%d]
### Example 2
This example contains three test conditions and four date formats.
Example 2
| Test | Date Range | Format String | Example |
|-------|------------|---------------|---------|
| '%[d' | Today | '%[%H:%M ] ' | 12:34 |
| '%[m' | This month | '%[%a %d]' | Thu 12 |
| '%[y' | This year | '%[%b %d]' | Dec 10 |
| | Older | '%[%m/%y ]' | 06/15 |
The $index_format string would contain:
%<[y?%<[m?%<[d?%[%H:%M ]&%[%a %d]>&%[%b %d]>&%[%m/%y ]>
Reparsed a little, for clarity, you can see the test conditions and the
four format strings.
%<[y? &%[%m/%y ]> Older
%<[m? &%[%b %d]> This year
%<[d? &%[%a %d]> This month
%[%H:%M ] Today
This a another view of the same example, with some whitespace for clarity.
%<[y? %<[m? %<[d? AAA & BBB > & CCC > & DDD >
AAA = %[%H:%M ]
BBB = %[%a %d]
CCC = %[%b %d]
DDD = %[%m/%y ]
Variables
---------
The "cond-date" patch doesn't have any config of its own. It modifies the
behavior of the format strings.
See Also
--------
* NeoMutt project
* $index_format
* nested-if patch
* 'strftime(3)'
Known Bugs
----------
Date parsing doesn't quite do what you expect. "1w" doesn't mean the "in
the last 7 days", but "*this* week". This doesn't match the normal Mutt
behaviour: for example '~d>1w' means emails dated in the last 7 days.
Credits
-------
* Aaron Schrab <[email protected]>
* Eric Davis <[email protected]>
* Richard Russon <[email protected]>