You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refines the DateTimeRange parsing examples in the README
to provide clearer and more comprehensive usage scenarios.
Adds examples for common date ranges, including last hour,
yesterday, last week, and last year.
Updates tests to validate new examples and clarify
rounding behavior with different bracket combinations.
Clarifies the behavior of exclusive upper bounds in date math
expressions, especially around zero-width ranges.
|`{now/d TO now/d]`| min: end, max: end | Empty (end = end) |
134
141
|`[now/M TO now/M]`| min: start of month, max: end of month | Entire current month |
135
-
|`[now/h TO now/h]`| min: start of hour, max: end of hour | Entire current hour |
136
142
137
143
Common date range patterns:
138
144
139
145
```text
146
+
// Last 15 minutes (rolling)
147
+
[now-15m TO now]
148
+
149
+
// Last hour (rounded to hour boundaries)
150
+
[now-1h/h TO now-1h/h]
151
+
152
+
// Last 4 full hours (rounded to hour boundaries)
153
+
[now-4h/h TO now/h]
154
+
155
+
// Last 24 hours (rolling, including partial today)
156
+
[now-24h TO now]
157
+
140
158
// Today (start of day through end of day)
141
159
[now/d TO now/d]
142
160
143
161
// Yesterday
144
162
[now-1d/d TO now-1d/d]
145
163
146
-
// This month
147
-
[now/M TO now/M]
148
-
149
-
// Last month
150
-
[now-1M/M TO now-1M/M]
151
-
152
164
// Last 7 full days (not including today)
153
165
[now-7d/d TO now-1d/d]
154
166
@@ -158,13 +170,25 @@ Common date range patterns:
158
170
// This week
159
171
[now/w TO now/w]
160
172
161
-
// Last hour
162
-
[now-1h/h TO now-1h/h]
173
+
// Last week
174
+
[now-1w/w TO now-1w/w]
163
175
164
-
// Last 4 full hours (rounded to hour boundaries)
165
-
[now-4h/h TO now/h]
176
+
// This month
177
+
[now/M TO now/M]
178
+
179
+
// Last month
180
+
[now-1M/M TO now-1M/M]
181
+
182
+
// Year to date (start of year through now)
183
+
[now/y TO now]
184
+
185
+
// Last year
186
+
[now-1y/y TO now-1y/y]
166
187
```
167
188
189
+
> **Important**: `[now-1d/d TO now-1d/d}` (same date, exclusive upper) produces a zero-width range because
190
+
> both sides round to start-of-day. Use `[now-1d/d TO now-1d/d]` (inclusive both ends) instead.
191
+
168
192
### DateMath Utility
169
193
170
194
For applications that need standalone date math parsing without the range functionality, the `DateMath` utility class provides direct access to Elasticsearch date math expression parsing. Check out our [unit tests](https://github.com/exceptionless/Exceptionless.DateTimeExtensions/blob/main/tests/Exceptionless.DateTimeExtensions.Tests/DateMathTests.cs) for more usage samples.
0 commit comments