diff options
author | Loïc Hoguin <[email protected]> | 2011-12-26 10:13:30 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-12-26 10:17:29 +0100 |
commit | 156c84ff29a13f3d21c1b7ff271bda50797ca0ef (patch) | |
tree | aa22d1276732949741e67c04774f1382b660d26c /src/cowboy_clock.erl | |
parent | 52c177fa6feedeed6a5fe565f13bf49cd61ef64e (diff) | |
download | cowboy-156c84ff29a13f3d21c1b7ff271bda50797ca0ef.tar.gz cowboy-156c84ff29a13f3d21c1b7ff271bda50797ca0ef.tar.bz2 cowboy-156c84ff29a13f3d21c1b7ff271bda50797ca0ef.zip |
Use calendar date and time types exported since R14B04
Removes the cowboy_clock:date/0, time/0 and datetime/0 exported types.
Diffstat (limited to 'src/cowboy_clock.erl')
-rw-r--r-- | src/cowboy_clock.erl | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl index 3597bdd..c699f4f 100644 --- a/src/cowboy_clock.erl +++ b/src/cowboy_clock.erl @@ -25,23 +25,8 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). %% gen_server. -%% @todo Use calendar types whenever they get exported. --type year() :: non_neg_integer(). --type month() :: 1..12. --type day() :: 1..31. --type hour() :: 0..23. --type minute() :: 0..59. --type second() :: 0..59. --type daynum() :: 1..7. - --type date() :: {year(), month(), day()}. --type time() :: {hour(), minute(), second()}. - --type datetime() :: {date(), time()}. --export_type([date/0, time/0, datetime/0]). - -record(state, { - universaltime = undefined :: undefined | datetime(), + universaltime = undefined :: undefined | calendar:datetime(), rfc1123 = <<>> :: binary(), tref = undefined :: undefined | timer:tref() }). @@ -74,7 +59,7 @@ rfc1123() -> %% %% This format is used in the <em>'Set-Cookie'</em> header sent with %% HTTP responses. --spec rfc2109(datetime()) -> binary(). +-spec rfc2109(calendar:datetime()) -> binary(). rfc2109(LocalTime) -> {{YYYY,MM,DD},{Hour,Min,Sec}} = case calendar:local_time_to_universal_time_dst(LocalTime) of @@ -145,7 +130,8 @@ code_change(_OldVsn, State, _Extra) -> %% Internal. --spec update_rfc1123(binary(), undefined | datetime(), datetime()) -> binary(). +-spec update_rfc1123(binary(), undefined | calendar:datetime(), + calendar:datetime()) -> binary(). update_rfc1123(Bin, Now, Now) -> Bin; update_rfc1123(<< Keep:23/binary, _/bits >>, @@ -184,7 +170,7 @@ pad_int(X) when X < 10 -> pad_int(X) -> list_to_binary(integer_to_list(X)). --spec weekday(daynum()) -> <<_:24>>. +-spec weekday(1..7) -> <<_:24>>. weekday(1) -> <<"Mon">>; weekday(2) -> <<"Tue">>; weekday(3) -> <<"Wed">>; @@ -193,7 +179,7 @@ weekday(5) -> <<"Fri">>; weekday(6) -> <<"Sat">>; weekday(7) -> <<"Sun">>. --spec month(month()) -> <<_:24>>. +-spec month(1..12) -> <<_:24>>. month( 1) -> <<"Jan">>; month( 2) -> <<"Feb">>; month( 3) -> <<"Mar">>; |