diff options
author | Loïc Hoguin <[email protected]> | 2012-03-09 22:22:37 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-03-09 22:22:37 +0100 |
commit | 5d46ad0e58623591ca97c42f76a4e0151d724047 (patch) | |
tree | 95b703c27c508a29c998243212f99cbe57dd5a24 /src | |
parent | c6c2b31695b6ee5a5d8b10e8b4c34baf510f8f25 (diff) | |
parent | 3376b7295e6903d7fb28ba97de5cd72688719fb7 (diff) | |
download | cowboy-5d46ad0e58623591ca97c42f76a4e0151d724047.tar.gz cowboy-5d46ad0e58623591ca97c42f76a4e0151d724047.tar.bz2 cowboy-5d46ad0e58623591ca97c42f76a4e0151d724047.zip |
Merge branch 'cookie-expire-fix' of https://github.com/klaar/cowboy
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_clock.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/cowboy_clock.erl b/src/cowboy_clock.erl index c699f4f..e22b718 100644 --- a/src/cowboy_clock.erl +++ b/src/cowboy_clock.erl @@ -64,7 +64,20 @@ rfc2109(LocalTime) -> {{YYYY,MM,DD},{Hour,Min,Sec}} = case calendar:local_time_to_universal_time_dst(LocalTime) of [Gmt] -> Gmt; - [_,Gmt] -> Gmt + [_,Gmt] -> Gmt; + [] -> + %% The localtime generated by cowboy_cookies may fall within + %% the hour that is skipped by daylight savings time. If this + %% is such a localtime, increment the localtime with one hour + %% and try again, if this succeeds, subtracting the max_age + %% from the resulting universaltime and converting to a local + %% time will yield the original localtime. + {Date, {Hour1, Min1, Sec1}} = LocalTime, + LocalTime2 = {Date, {Hour1 + 1, Min1, Sec1}}, + case calendar:local_time_to_universal_time_dst(LocalTime2) of + [Gmt] -> Gmt; + [_,Gmt] -> Gmt + end end, Wday = calendar:day_of_the_week({YYYY,MM,DD}), DayBin = pad_int(DD), |