From d1210020c6de29db3c3309c5cf77217a8989344d Mon Sep 17 00:00:00 2001 From: nkottary Date: Tue, 24 Nov 2015 10:00:22 +0530 Subject: [PATCH 1/2] Fix timestamp issue --- src/results.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/results.jl b/src/results.jl index 672b90e..14f8988 100644 --- a/src/results.jl +++ b/src/results.jl @@ -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 From 36df4ff3fb61b32037491845cafd6fc15ebf7ad4 Mon Sep 17 00:00:00 2001 From: nkottary Date: Tue, 24 Nov 2015 11:42:46 +0530 Subject: [PATCH 2/2] Added optional convert methods for Date and Datetime for Dates module --- REQUIRE | 3 ++- src/datetime.jl | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 144f796..26c7447 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,3 @@ DataFrames -Compat \ No newline at end of file +Compat +Requires \ No newline at end of file diff --git a/src/datetime.jl b/src/datetime.jl index c916906..37f4c5c 100644 --- a/src/datetime.jl +++ b/src/datetime.jl @@ -1,5 +1,7 @@ # Constructors for the julia Date, Time and DateTime types. +using Requires + import Base.== function MySQLTime(timestr) @@ -77,3 +79,11 @@ end function ==(a::MySQLDateTime, b::MySQLDateTime) a.date == b.date && a.time == b.time end + +@require Dates begin +using Dates +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