nolta/Calendar.jl — pull request #10 by tshort (2013-01-31 00:58:44+00:00)
Title: Add vectorizing methods

Here are examples:

```julia
julia> using Calendar

julia> x = [now():days(1):now() + weeks(1)]
8-element CalendarTime Array:
Jan 30, 2013 7:40:27 PM EST
Jan 31, 2013 7:40:27 PM EST
Feb 1, 2013 7:40:27 PM EST
Feb 2, 2013 7:40:27 PM EST
Feb 3, 2013 7:40:27 PM EST
Feb 4, 2013 7:40:27 PM EST
Feb 5, 2013 7:40:27 PM EST
Feb 6, 2013 7:40:27 PM EST

julia> x + hours(1)
8-element CalendarTime Array:
Jan 30, 2013 8:40:27 PM EST
Jan 31, 2013 8:40:27 PM EST
Feb 1, 2013 8:40:27 PM EST
Feb 2, 2013 8:40:27 PM EST
Feb 3, 2013 8:40:27 PM EST
Feb 4, 2013 8:40:27 PM EST
Feb 5, 2013 8:40:27 PM EST
Feb 6, 2013 8:40:27 PM EST

julia> dayofweek(x)
8-element Int64 Array:
4
5
6
7
1
2
3
4

julia> month(x) .== January
8-element BitArray:
true
true
false
false
false
false
false
false

julia> x = parse("yyyy-MM-dd", ["2011-06-02", "2012-04-05"])
2-element CalendarTime Array:
Jun 2, 2011 12:00:00 AM EDT
Apr 5, 2012 12:00:00 AM EDT

julia> y = [now(), now() + days(2)]
2-element CalendarTime Array:
Jan 30, 2013 7:42:56 PM EST
Feb 1, 2013 7:42:56 PM EST

julia> x .> y
2-element BitArray:
false
false

julia> using DataFrames

julia> d = @DataFrame(x => 1:5, date => [now():days(1):now() + days(4)])
5x2 DataFrame:
x date
[1,] 1 Jan 30, 2013 7:50:33 PM EST
[2,] 2 Jan 31, 2013 7:50:33 PM EST
[3,] 3 Feb 1, 2013 7:50:33 PM EST
[4,] 4 Feb 2, 2013 7:50:33 PM EST
[5,] 5 Feb 3, 2013 7:50:33 PM EST

julia> d[d["date"] .< ymd(2013, 2, 2), :]
3x2 DataFrame:
x date
[1,] 1 Jan 30, 2013 7:50:33 PM EST
[2,] 2 Jan 31, 2013 7:50:33 PM EST
[3,] 3 Feb 1, 2013 7:50:33 PM EST
```

Not all functions are vectorized. The most notable that are not are `ymd` and `ymd_hms`. I'm not sure of the best way to vectorize these because they have so many arguments. Something like `ymd(y, m, 1) + days(d) - 1 + hm(h, m) + seconds(s)` is one way, but that may create a lot of temporaries.

Also, I really like your design and API. There's a lot of functionality with not much code.