JuliaLang/julia — pull request #698 by aviks (2012-04-10 20:11:12+00:00)
Title: RFC: Dates

So here is an initial support for Date and DateTime objects in Julia. Currently implemented is date arithmetic.

```jlcon

julia> a=now()
10 Apr 2012 16:21:34.488 BST

julia> typeof(a)
DateTime
Methods for generic function DateTime
DateTime(Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,String)

julia> b=convert(Date, a)
10 Apr 2012

julia> c=Date(2012, 4,9)
9 Apr 2012

julia> b-c
1

julia> c+1 == b
true

julia> yday(c)
100

julia> day_of_week(c)
2
```

There are more things to do of course. First is to implement similar date arithmetic on DateTime. The big one however is date formats and parsing... that's a large piece of work by itself. However, the current functionality is self contained and useful.

There are quite a few tests in tests/date.jl

I've had to read a struct off libc, and so there is some simple but dirty looking C code in support/timefuncs.c/h. Not sure if that is the best way.

Let me know what you guys think about all this.