AmericasCalendarData Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.Americas.dll
- Package
- Bodu.Globalization.Calendar.Americas 1.0.0
- Source
- AmericasCalendarData.cs
Provides access to the embedded Americas notable-date resource pack (Canada and the United States), built on the notable-date schema.
public static class AmericasCalendarData
- Inheritance
-
AmericasCalendarData
- Inherited Members
Examples
// Query United States federal holidays for a year.
NotableDateService service = AmericasCalendarData.CreateService("US");
DateRange year = new(new DateOnly(2026, 1, 1), new DateOnly(2026, 12, 31));
IReadOnlyList<NotableDate> holidays = service.Resolve(year, "US");
// A subdivision sees its province's rules layered over the country's.
NotableDateService ontario = AmericasCalendarData.CreateService("CA-ON");
Remarks
Each supported country is a self-contained embedded resource. A territory may be a country code (US) or a
subdivision (CA-ON); the subdivision selects the same country resource, and the resolver filters by the full
territory at query time.
When to use. Call CreateService(string) for a ready-to-query NotableDateService, or LoadResource(string) when you need the underlying NotableDateResource to compose with custom collaborators or providers.
Properties
SupportedCountries
Gets the country codes the Americas pack provides resources for.
public static IReadOnlyList<string> SupportedCountries { get; }
Property Value
- IReadOnlyList<string>
The supported ISO 3166-1 alpha-2 country codes.
Methods
CreateService(string)
Builds a resolver over the resource for the country owning the supplied territory.
public static NotableDateService CreateService(string territory)
Parameters
territorystringA country code or subdivision (for example
USorCA-ON).
Returns
- NotableDateService
A service over the country's resource.
Exceptions
- ArgumentNullException
territoryis null.- ArgumentException
The territory's country is not provided by this pack.
LoadResource(string)
Loads the notable-date resource for the country owning the supplied territory.
public static NotableDateResource LoadResource(string territory)
Parameters
territorystringA country code or subdivision (for example
USorCA-ON).
Returns
- NotableDateResource
The loaded NotableDateResource.
Exceptions
- ArgumentNullException
territoryis null.- ArgumentException
The territory's country is not provided by this pack.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |