Permalink
Browse files

trying a fix from Klaar's branch, in our older version

  • Loading branch information...
ferd committed Mar 9, 2012
1 parent c7be41b commit 03c03d9233784a6e36ffa02955dbbfa08a21edfc
Showing with 17 additions and 4 deletions.
  1. +17 −4 src/cowboy_clock.erl
View
@@ -77,10 +77,23 @@ rfc1123() ->
-spec rfc2109(datetime()) -> binary().
rfc2109(LocalTime) ->
{{YYYY,MM,DD},{Hour,Min,Sec}} =
- case calendar:local_time_to_universal_time_dst(LocalTime) of
- [Gmt] -> Gmt;
- [_,Gmt] -> Gmt
- end,
+ case calendar:local_time_to_universal_time_dst(LocalTime) of
+ [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),
YearBin = list_to_binary(integer_to_list(YYYY)),

0 comments on commit 03c03d9

Please sign in to comment.