Skip to content

Commit

Permalink
Let the pgsql driver convert textual dates to dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed May 7, 2012
1 parent 0537a12 commit 1c3af59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions deps/dh_date
Submodule dh_date added at 39937c
8 changes: 6 additions & 2 deletions src/dbdrivers/postgresql/epgsql/pgsql_datetime.erl
Expand Up @@ -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) ->
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1c3af59

Please sign in to comment.