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
Copy file name to clipboardexpand all lines: doc/manual/dates.rst
+29-4
Original file line number
Diff line number
Diff line change
@@ -260,6 +260,33 @@ What's going on there? In the first line, we're adding 1 day to January 29th, wh
260
260
261
261
Tricky? Perhaps. What is an innocent :mod:`Dates` user to do? The bottom line is to be aware that explicitly forcing a certain associativity, when dealing with months, may lead to some unexpected results, but otherwise, everything should work as expected. Thankfully, that's pretty much the extent of the odd cases in date-period arithmetic when dealing with time in UT (avoiding the "joys" of dealing with daylight savings, leap seconds, etc.).
262
262
263
+
As a bonus, all period arithmetic objects work directly with ranges::
264
+
265
+
julia> dr = Date(2014,1,29):Date(2014,2,3)
266
+
2014-01-29:1 day:2014-02-03
267
+
268
+
julia> collect(dr)
269
+
6-element Array{Date,1}:
270
+
2014-01-29
271
+
2014-01-30
272
+
2014-01-31
273
+
2014-02-01
274
+
2014-02-02
275
+
2014-02-03
276
+
277
+
julia> dr = Date(2014,1,29):Dates.Month(1):Date(2014,07,29)
278
+
2014-01-29:1 month:2014-07-29
279
+
280
+
julia> collect(dr)
281
+
7-element Array{Date,1}:
282
+
2014-01-29
283
+
2014-02-28
284
+
2014-03-29
285
+
2014-04-29
286
+
2014-05-29
287
+
2014-06-29
288
+
2014-07-29
289
+
263
290
264
291
Adjuster Functions
265
292
------------------
@@ -305,14 +332,12 @@ This is useful with the do-block syntax for more complex temporal expressions::
305
332
end
306
333
2014-11-27
307
334
308
-
The final method in the adjuster API is the :func:`recur` function. :func:`recur` vectorizes the adjustment process by taking a start and stop date (optionally specificed by a :class:`StepRange`), along with a :class:`DateFunction` to specify all valid dates/moments to be returned in the specified range. In this case, the :class:`DateFunction` is often referred to as the "inclusion" function because it specifies (by returning ``true``) which dates/moments should be included in the returned vector of dates.
309
-
310
-
::
335
+
The :func:`Base.filter` method can be used to obtain all valid dates/moments in a specified range::
311
336
312
337
# Pittsburgh street cleaning; Every 2nd Tuesday from April to November
313
338
# Date range from January 1st, 2014 to January 1st, 2015
0 commit comments