Table of Contents

IQuarterDefinitionProvider Interface

Definition

Namespace
Bodu.Extensions
Assembly
Bodu.Core.dll
Package
Bodu.Core 1.0.1
Source
IQuarterDefinitionProvider.cs

Defines a provider interface for custom quarter calculation logic based on DateTime or DateOnly values.

public interface IQuarterDefinitionProvider
Extension Methods

Remarks

Implementations describe a recurring quarter rule - a fiscal or logical calendar definition that is independent of any single year. Year-specific values, such as quarter start and end dates or whether a fiscal year contains a 53rd week, are derived on demand from the DateTime or DateOnly input, or from an explicit fiscalYear argument.

Example use cases include 4-4-5 calendars, academic terms, retail fiscal calendars, or historical reporting quarters that do not align with calendar or standard financial quarters.

Methods that support this interface include:

Methods

GetFiscalYear(DateOnly)

Returns the fiscal year that contains the supplied DateOnly.

int GetFiscalYear(DateOnly dateOnly)

Parameters

dateOnly DateOnly

The date to identify.

Returns

int

The fiscal year number under the provider's conventions.

Exceptions

ArgumentOutOfRangeException

Thrown when dateOnly cannot be mapped to any fiscal year known to the provider.

GetFiscalYear(DateTime)

Returns the fiscal year that contains the supplied DateTime.

int GetFiscalYear(DateTime dateTime)

Parameters

dateTime DateTime

The date to identify.

Returns

int

The fiscal year number under the provider's conventions.

Remarks

The default implementation probes the calendar years dateTime.Year - 1, dateTime.Year, and dateTime.Year + 1, returning the candidate whose Q1 start and Q4 end bracket dateTime . This works for any provider whose fiscal year is contiguous and at most one calendar year away from the observed calendar year. Implementations may override with a more efficient or more precise computation.

Exceptions

ArgumentOutOfRangeException

Thrown when dateTime cannot be mapped to any fiscal year known to the provider.

GetQuarter(DateOnly)

Returns the quarter number (1-4) that contains the specified DateOnly.

int GetQuarter(DateOnly dateOnly)

Parameters

dateOnly DateOnly

The input DateOnly for which to determine the quarter.

Returns

int

An integer in the range 1 to 4 representing the quarter that includes dateOnly.

Exceptions

ArgumentOutOfRangeException

Thrown when dateOnly cannot be mapped to a recognized fiscal year.

GetQuarter(DateTime)

Returns the quarter number (1-4) that contains the specified DateTime.

int GetQuarter(DateTime dateTime)

Parameters

dateTime DateTime

The input DateTime for which to determine the quarter.

Returns

int

An integer in the range 1 to 4 representing the quarter that includes dateTime.

Exceptions

ArgumentOutOfRangeException

Thrown when dateTime cannot be mapped to a recognized fiscal year.

GetQuarterEnd(DateTime)

Returns the last day of the quarter that contains the specified DateTime.

DateTime GetQuarterEnd(DateTime dateTime)

Parameters

dateTime DateTime

The input DateTime for which to determine the end of the quarter.

Returns

DateTime

A DateTime set to midnight (00:00:00) on the final day of the quarter that includes dateTime. The result preserves the original Kind.

Exceptions

ArgumentOutOfRangeException

Thrown when dateTime cannot be mapped to a recognized fiscal year.

GetQuarterEnd(int, int)

Returns the last day of the specified quarter number (1-4) within the given fiscal year.

DateTime GetQuarterEnd(int quarter, int fiscalYear)

Parameters

quarter int

The quarter number (1-4).

fiscalYear int

The fiscal year whose quarter boundary is being requested.

Returns

DateTime

A DateTime set to midnight (00:00:00) on the last day of the specified quarter.

Exceptions

ArgumentOutOfRangeException

Thrown when quarter is not between 1 and 4.

GetQuarterEndDate(DateOnly)

Returns the last day of the quarter that contains the specified DateOnly.

DateOnly GetQuarterEndDate(DateOnly dateOnly)

Parameters

dateOnly DateOnly

The input DateOnly for which to determine the end of the quarter.

Returns

DateOnly

A DateOnly representing the final day of the quarter that includes dateOnly.

Exceptions

ArgumentOutOfRangeException

Thrown when dateOnly cannot be mapped to a recognized fiscal year.

GetQuarterEndDate(int, int)

Returns the last day of the specified quarter number (1-4) within the given fiscal year.

DateOnly GetQuarterEndDate(int quarter, int fiscalYear)

Parameters

quarter int

The quarter number (1-4).

fiscalYear int

The fiscal year whose quarter boundary is being requested.

Returns

DateOnly

A DateOnly representing the final day of the specified quarter.

Exceptions

ArgumentOutOfRangeException

Thrown when quarter is not between 1 and 4.

GetQuarterStart(DateTime)

Returns the first day of the quarter that contains the specified DateTime.

DateTime GetQuarterStart(DateTime dateTime)

Parameters

dateTime DateTime

The input DateTime for which to determine the start of the quarter.

Returns

DateTime

A DateTime set to midnight (00:00:00) on the first day of the quarter that includes dateTime. The result preserves the original Kind.

Exceptions

ArgumentOutOfRangeException

Thrown when dateTime cannot be mapped to a recognized fiscal year.

GetQuarterStart(int, int)

Returns the first day of the specified quarter number (1-4) within the given fiscal year.

DateTime GetQuarterStart(int quarter, int fiscalYear)

Parameters

quarter int

The quarter number (1-4).

fiscalYear int

The fiscal year whose quarter boundary is being requested.

Returns

DateTime

A DateTime set to midnight (00:00:00) on the first day of the specified quarter.

Exceptions

ArgumentOutOfRangeException

Thrown when quarter is not between 1 and 4.

GetQuarterStartDate(DateOnly)

Returns the first day of the quarter that contains the specified DateOnly.

DateOnly GetQuarterStartDate(DateOnly dateOnly)

Parameters

dateOnly DateOnly

The input DateOnly for which to determine the start of the quarter.

Returns

DateOnly

A DateOnly representing the first day of the quarter that includes dateOnly.

Exceptions

ArgumentOutOfRangeException

Thrown when dateOnly cannot be mapped to a recognized fiscal year.

GetQuarterStartDate(int, int)

Returns the first day of the specified quarter number (1-4) within the given fiscal year.

DateOnly GetQuarterStartDate(int quarter, int fiscalYear)

Parameters

quarter int

The quarter number (1-4).

fiscalYear int

The fiscal year whose quarter boundary is being requested.

Returns

DateOnly

A DateOnly representing the first day of the specified quarter.

Exceptions

ArgumentOutOfRangeException

Thrown when quarter is not between 1 and 4.

GetWeeksInFiscalYear(int)

Returns the total number of weeks in the specified fiscal year.

int GetWeeksInFiscalYear(int fiscalYear)

Parameters

fiscalYear int

The fiscal year to query.

Returns

int

53 in a 53-week fiscal year; otherwise, 52.

Is53WeekFiscalYear(int)

Returns a value indicating whether the specified fiscal year contains 53 weeks rather than the standard 52.

bool Is53WeekFiscalYear(int fiscalYear)

Parameters

fiscalYear int

The fiscal year to test.

Returns

bool

true if the fiscal year spans 371 days (53 complete weeks); false if it spans 364 days (52 complete weeks).

Applies to

ProductVersions
.NET8, 10