karbarcca/Datetime.jl — pull request #34 by stephencpope (2014-01-15 23:47:38+00:00)
Title: Date to DateTime conversion ignores leap seconds

The Datetime package convert method for Date -> DateTime ignores leap seconds, leading to the following unexpected behavior:

```
julia> Pkg.status()
1 required packages:
- Datetime 0.1.2+ master

julia> date(2012,7,1)
2012-07-01

julia> datetime(date(2012,7,1))
2012-06-30T23:59:36 UTC

julia> date(datetime(date(2012,7,1)))
2012-06-30
```

The problem is the following conversion method:

```
convert{T<:Offsets}(::Type{DateTime{ISOCalendar,T}},x::Date) = convert(DateTime{ISOCalendar,T},86400000*int64(x))
```

After my proposed corrections:

```
julia> date(2012,7,1)
2012-07-01

julia> datetime(date(2012,7,1))
2012-07-01T00:00:00 UTC

julia> date(datetime(date(2012,7,1)))
2012-07-01
```

At the same time, I added support for specifying a non-default timezone, so that a DateTime which is midnight in the specified zone on the specified date is created:

```
julia> datetime(date(2012,7,1), Datetime.Zone389)
2012-07-01T00:00:00 MDT

julia> datetime(date(2012,7,1), MST)
2012-07-01T00:00:00 MDT

julia> datetime(date(2012,7,1), "America/Denver")
2012-07-01T00:00:00 MDT
```

By the way, the issue was missed in test.jl because Date -> DateTime conversion was only tested for using date(1,1,1) which is prior to any leap seconds. I have also added a few appropriate tests at the end of test.jl, because I wasn’t sure exactly where else to best insert them.

Please excuse any improprieties on my part, I am new to Julia, GitHub, and the process of submitting pull requests. Kindly let me know if there's a better way to do it!