@@ -97,16 +97,17 @@ defmodule Tzdata.PeriodBuilder do
9797 def h_calc_next_zone_line ( _btz_data , period , _ , zone_line_tl , _ ) when zone_line_tl == [ ] do
9898 case period do
9999 nil -> [ ]
100- _ -> [ period ]
100+ _ -> [ period ]
101101 end
102102 end
103103
104104 # If there is a zone line tail, we recursively add to the list of periods with that zone line tail
105105 def h_calc_next_zone_line ( btz_data , period , until_utc , zone_line_tl , letter ) do
106106 tail = calc_periods ( btz_data , zone_line_tl , until_utc , hd ( zone_line_tl ) . rules , letter )
107+
107108 case period do
108109 nil -> tail
109- _ -> [ period | tail ]
110+ _ -> [ period | tail ]
110111 end
111112 end
112113
@@ -194,8 +195,12 @@ defmodule Tzdata.PeriodBuilder do
194195 letter
195196 ) do
196197 until_utc = datetime_to_utc ( Map . get ( zone_line , :until ) , utc_off , std_off )
197- tail = calc_periods ( btz_data , zone_line_tl , until_utc , Map . get ( hd ( zone_line_tl ) , :rules ) , letter )
198- if from == until_utc do # empty period may happen when 'until' of zone line coincides with end of rule
198+
199+ tail =
200+ calc_periods ( btz_data , zone_line_tl , until_utc , Map . get ( hd ( zone_line_tl ) , :rules ) , letter )
201+
202+ # empty period may happen when 'until' of zone line coincides with end of rule
203+ if from == until_utc do
199204 tail
200205 else
201206 from_standard_time = standard_time_from_utc ( from , utc_off )
@@ -211,7 +216,7 @@ defmodule Tzdata.PeriodBuilder do
211216 zone_abbr: TzUtil . period_abbrevation ( zone_line . format , std_off , letter )
212217 }
213218
214- [ period | tail ]
219+ [ period | tail ]
215220 end
216221 end
217222
@@ -286,9 +291,14 @@ defmodule Tzdata.PeriodBuilder do
286291
287292 until_utc = datetime_to_utc ( TzUtil . time_for_rule ( rule , year ) , utc_off , std_off )
288293 # truncate end of period to within time range of zone line
289- until_before_lower_limit = is_integer ( lower_limit ) && is_integer ( until_utc ) && lower_limit > until_utc
294+ until_before_lower_limit =
295+ is_integer ( lower_limit ) && is_integer ( until_utc ) && lower_limit > until_utc
296+
290297 until_utc = if until_before_lower_limit , do: lower_limit , else: until_utc
291- last_included_rule = is_integer ( upper_limit ) && is_integer ( until_utc ) && upper_limit <= until_utc
298+
299+ last_included_rule =
300+ is_integer ( upper_limit ) && is_integer ( until_utc ) && upper_limit <= until_utc
301+
292302 until_utc = if last_included_rule , do: upper_limit , else: until_utc
293303 # derive standard and wall time for 'until'
294304 until_standard_time = standard_time_from_utc ( until_utc , utc_off )
@@ -313,38 +323,41 @@ defmodule Tzdata.PeriodBuilder do
313323
314324 # If we've hit the upper time boundary of this zone line, we do not need to examine any more
315325 # rules for this rule set OR there are no more years to consider for this rule set
316- if last_included_rule || no_more_years && no_more_rules do
326+ if last_included_rule || ( no_more_years && no_more_rules ) do
317327 h_calc_next_zone_line ( btz_data , period , until_utc , zone_line_tl , letter )
318328 else
319- tail = cond do
320- # If there are no more rules for the year, continue with the next year
321- no_more_rules ->
322- calc_rule_periods (
323- btz_data ,
324- [ zone_line | zone_line_tl ] ,
325- until_utc ,
326- utc_off ,
327- rule . save ,
328- years |> tl ,
329- zone_rules ,
330- rule . letter
331- )
332- # Else continue with those rules
333- true ->
334- calc_periods_for_year (
335- btz_data ,
336- [ zone_line | zone_line_tl ] ,
337- until_utc ,
338- utc_off ,
339- rule . save ,
340- years ,
341- zone_rules ,
342- rules_tail ,
343- rule . letter ,
344- lower_limit
345- )
346- end
347- if period == nil , do: tail , else: [ period | tail ]
329+ tail =
330+ cond do
331+ # If there are no more rules for the year, continue with the next year
332+ no_more_rules ->
333+ calc_rule_periods (
334+ btz_data ,
335+ [ zone_line | zone_line_tl ] ,
336+ until_utc ,
337+ utc_off ,
338+ rule . save ,
339+ years |> tl ,
340+ zone_rules ,
341+ rule . letter
342+ )
343+
344+ # Else continue with those rules
345+ true ->
346+ calc_periods_for_year (
347+ btz_data ,
348+ [ zone_line | zone_line_tl ] ,
349+ until_utc ,
350+ utc_off ,
351+ rule . save ,
352+ years ,
353+ zone_rules ,
354+ rules_tail ,
355+ rule . letter ,
356+ lower_limit
357+ )
358+ end
359+
360+ if period == nil , do: tail , else: [ period | tail ]
348361 end
349362 end
350363
@@ -353,9 +366,9 @@ defmodule Tzdata.PeriodBuilder do
353366 def sort_rules_by_time ( rules , year ) do
354367 # n.b., we can have many rules per month - such as time changes for religious festivals
355368 rules
356- |> Enum . map ( & ( { & 1 , TzUtil . tz_day_to_date ( year , & 1 . in , & 1 . on ) } ) )
369+ |> Enum . map ( & { & 1 , TzUtil . tz_day_to_date ( year , & 1 . in , & 1 . on ) } )
357370 |> Enum . sort ( & ( elem ( & 1 , 1 ) < elem ( & 2 , 1 ) ) )
358- |> Enum . map ( & ( elem ( & 1 , 0 ) ) )
371+ |> Enum . map ( & elem ( & 1 , 0 ) )
359372 end
360373
361374 @ doc """
0 commit comments