Canada achieved legislative independence from Britain through the passage of the Constitution Act, 1867, formerly known as the British North America Act, on July 1, 1867. This act united the provinces of Canada, Nova Scotia, and New Brunswick into the Dominion of Canada, a self-governing entity within the British Empire.
It's important to note that while Canada gained legislative independence in 1867, full sovereignty and constitutional independence were achieved gradually. The process culminated with the patriation of the Canadian Constitution in 1982, which included the Constitution Act, 1982. This act granted Canada full control over its constitution, including the ability to amend it without requiring approval from the British Parliament.
In terms of the years Britain ruled Canada, prior to legislative independence in 1867, the regions that would become Canada were colonies under British rule. The history of British rule in Canada dates back to the early 16th century with the exploration and subsequent colonization by European powers, including France and Britain. The specific duration of British rule can vary depending on the region within Canada, but it spanned several centuries before Canada became a self-governing dominion.