Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timestamp issue #27

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DataFrames
Compat
Compat
Requires
10 changes: 10 additions & 0 deletions src/datetime.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Constructors for the julia Date, Time and DateTime types.

using Requires

import Base.==

function MySQLTime(timestr)
Expand Down Expand Up @@ -77,3 +79,11 @@ end
function ==(a::MySQLDateTime, b::MySQLDateTime)
a.date == b.date && a.time == b.time
end

@require Dates begin
using Dates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dates is not that big a dependency, and it is built into base in 0.4. Is Requires.jl worth it here?

Base.convert(::Type{Date}, date::MySQLDate) = Date(date.year, date.month, date.day)
Base.convert(::Type{DateTime}, dtime::MySQLDateTime) =
DateTime(dtime.date.year, dtime.date.month, dtime.date.day,
dtime.time.hour, dtime.time.minute, dtime.time.second)
end
2 changes: 1 addition & 1 deletion src/results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function mysql_get_julia_type(mysqltype::MYSQL_TYPE)
return Clong

elseif (mysqltype == MYSQL_TYPE_TIMESTAMP)
return Cint
return MySQLDateTime

elseif (mysqltype == MYSQL_TYPE_DATE)
return MySQLDate
Expand Down