Browse Source

Revert date filter changes from 313edd5edd376ca12b773285a261086138120f20.

I don't mind the unix epoch features as such. But they belong in
another filter module, as it's not a feature of Django.
Andreas Stenius 11 years ago
parent
commit
32455f923a
1 changed files with 6 additions and 20 deletions
  1. 6 20
      src/erlydtl_filters.erl

+ 6 - 20
src/erlydtl_filters.erl

@@ -56,7 +56,6 @@
         cut/2,
         date/1,
         date/2,
-        date_unix_epoch/1,
         default/2,
         default_if_none/2,
         dictsort/2,
@@ -240,25 +239,13 @@ date(Input) ->
     date(Input, "F j, Y").
 
 %% @doc Formats a date according to the given format.
-date(undefined, _) -> "undefined";
-date(Input, FormatStr) when is_binary(Input) ->
-    list_to_binary(date(binary_to_list(Input), FormatStr));
-%% @doc format calendar:gregorian_seconds to string (year starts at year 0, not 1970. Use date_unix_epoch for latter).
-date(Input, FormatStr) when is_integer(Input) ->
-    date(calendar:gregorian_seconds_to_datetime(Input), FormatStr);
-date({{_,_,_} = Date,{_,_,_} = Time}, FormatStr) ->
-    erlydtl_dateformat:format({Date, Time}, FormatStr);
-date({_,_,_} = Date, FormatStr) ->
-    erlydtl_dateformat:format(Date, FormatStr);
-date(Input, _FormatStr) when is_list(Input) ->
-    io:format("Unexpected date parameter : ~p~n", [Input]),
+date(Input, FormatStr)
+  when is_tuple(Input)
+       andalso (size(Input) == 2 orelse size(Input) == 3) ->
+    erlydtl_dateformat:format(Input, FormatStr);
+date(Input, _FormatStr) ->
+    io:format("Unexpected date parameter: ~p~n", [Input]),
     "".
-%% @doc format a date given in unix-epoch seconds.
-%% Input is seconds since 1-1-1970. 
-%%% offset is calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}), the difference between 
-%%% gregorian calendar and unix epoch.
-date_unix_epoch(Input) ->
-    date(Input + 62167219200).
 
 %% @doc If value evaluates to `false', use given default. Otherwise, use the value.
 default(Input, Default) ->
@@ -510,7 +497,6 @@ phone2numeric(Input) when is_list(Input) ->
 %% @doc Returns a plural suffix if the value is not 1. By default, this suffix is 's'.
 pluralize(Number, Suffix) when is_binary(Suffix) ->
     pluralize_io(Number, binary_to_list(Suffix) );
-
 pluralize(Number, Suffix) when is_list(Suffix) ->
     pluralize_io(Number, Suffix).