Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

- Correct the time zones for Nunavut postal codes in Kitikmeot, Kivalliq, Resolute and Arctic Bay. [#685](https://github.com/Shopify/worldwide/pull/685)
- Add an `AGENTS.md` contribution guide and document when contributors need a changelog entry. [#686](https://github.com/Shopify/worldwide/pull/686)
- Add the `postal:codes:import`, `postal:codes:check` and `postal:codes:zone_check` rake tasks. They build and check the `zip_prefixes` and `zips_crossing_provinces` data in `data/regions/<CC>.yml`. [#680](https://github.com/Shopify/worldwide/pull/680)

Expand Down
38 changes: 21 additions & 17 deletions data/regions/CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ timezones:
- G0G 2P
- G0G 2R
- G0G 2W
America/Cambridge_Bay:
- X0B
America/Edmonton:
- S0M 0A4
- S0M 0A8
Expand Down Expand Up @@ -491,7 +493,6 @@ timezones:
- V0E 2L
- V1A
- V1C
- X0B
- X0E
- X0G
- X1
Expand All @@ -509,6 +510,22 @@ timezones:
- G0C 0E9
- G0C 2R
- G4T
America/Iqaluit:
- X0A 0A0
- X0A 0B3
America/Rankin_Inlet:
- X0C 0A0
- X0C 0A1
- X0C 0A3
- X0C 0A4
- X0C 0A5
- X0C 0A6
- X0C 0A7
- X0C 0B
- X0C 0E
- X0C 0G
- X0C 0H
- X0C 0J
America/Regina:
- S0A
- S0C
Expand Down Expand Up @@ -614,6 +631,9 @@ timezones:
- S9A
- S9H
- S9X
America/Resolute:
- X0A 0A2
- X0A 0V
America/St_Johns:
- A0A
- A0B
Expand Down Expand Up @@ -1092,19 +1112,3 @@ timezones:
- S0P 0A1
- S0P 0A2
- S0P 0B
- X0A 0A0
- X0A 0A2
- X0A 0B3
- X0A 0V
- X0C 0A0
- X0C 0A1
- X0C 0A3
- X0C 0A4
- X0C 0A5
- X0C 0A6
- X0C 0A7
- X0C 0B
- X0C 0E
- X0C 0G
- X0C 0H
- X0C 0J
45 changes: 45 additions & 0 deletions test/worldwide/regions/ca_test.rb
Comment thread
JoyceMiryamH marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require "test_helper"

module Worldwide
class CaTest < ActiveSupport::TestCase
test "Nunavut and neighboring postal codes have the correct timezone prefixes" do
expected_timezones = {
"X0B 0C0" => "America/Cambridge_Bay",
"X0B 1J0" => "America/Cambridge_Bay",
"X0C 0A0" => "America/Rankin_Inlet",
"X0C 0A1" => "America/Rankin_Inlet",
"X0C 0A3" => "America/Rankin_Inlet",
"X0C 0A4" => "America/Rankin_Inlet",
"X0C 0A5" => "America/Rankin_Inlet",
"X0C 0A6" => "America/Rankin_Inlet",
"X0C 0A7" => "America/Rankin_Inlet",
"X0C 0B0" => "America/Rankin_Inlet",
"X0C 0E0" => "America/Rankin_Inlet",
"X0C 0G0" => "America/Rankin_Inlet",
"X0C 0H0" => "America/Rankin_Inlet",
"X0C 0J0" => "America/Rankin_Inlet",
"X0A 0V0" => "America/Resolute",
"X0A 0A2" => "America/Resolute",
"X0A 0A0" => "America/Iqaluit",
"X0A 0B3" => "America/Iqaluit",
"X0A 0H0" => "America/Toronto",
"X0C 0A2" => "America/Atikokan",
"X0C 0C0" => "America/Atikokan",
"X0E 0A0" => "America/Edmonton",
"X0G 0A0" => "America/Edmonton",
"X1A 2N8" => "America/Edmonton",
"T5J 2R7" => "America/Edmonton",
"R3C 4T3" => "America/Winnipeg",
}

timezones = Worldwide.region(code: "CA").timezones
expected_timezones.each do |postal_code, timezone|
matches = timezones.select { |_name, prefixes| prefixes.any? { |prefix| postal_code.start_with?(prefix) } }.keys

assert_equal [timezone], matches, postal_code
end
end
end
end
Loading