Permalink
Browse files

Let the pgsql driver convert textual dates to dates.

  • Loading branch information...
mworrell committed May 7, 2012
1 parent 0537a12 commit 1c3af59e4a79488870a2014d088df3e1a8e5af3a
Showing with 7 additions and 2 deletions.
  1. +1 −0 deps/dh_date
  2. +6 −2 src/dbdrivers/postgresql/epgsql/pgsql_datetime.erl
Submodule dh_date added at 39937c
@@ -124,7 +124,9 @@ timestamp2f({_D,_M,_Y} = Date) ->
timestamp2f({Date, {0,0,0}});
timestamp2f({Date, Time}) ->
D = date2j(Date) - ?postgres_epoc_jdate,
- D * ?secs_per_day + time2f(Time).
+ D * ?secs_per_day + time2f(Time);
+timestamp2f(Date) when is_binary(Date); is_list(Date) ->
+ timestamp2f(dh_date:parse(Date)).
i2timestamp(N) ->
@@ -152,7 +154,9 @@ i2time(N) ->
timestamp2i({_D,_M,_Y} = Date) ->
timestamp2i({Date, {0,0,0}});
timestamp2i({Date, Time}) ->
- time2i(Time) + (date2j(Date) - ?postgres_epoc_jdate) * ?iusecs_per_day.
+ time2i(Time) + (date2j(Date) - ?postgres_epoc_jdate) * ?iusecs_per_day;
+timestamp2i(Date) when is_list(Date); is_binary(Date) ->
+ timestamp2i(dh_date:parse(Date)).
time2i({H, M, S}) ->
H * ?iusecs_per_hour + M * ?iusecs_per_minute + S * ?iusecs_per_sec.

0 comments on commit 1c3af59

Please sign in to comment.