Bodu.Globalization.Extensions Namespace
- Package
-
Bodu.Core 1.0.1
Purpose
Bodu.Globalization.Extensions is a small companion namespace in the Bodu.Core package holding a single extension class over the BCL DateTimeFormatInfo. It answers one question the BCL leaves open - a culture declares the day its week starts on (FirstDayOfWeek), but not the day it ends on - and the week-boundary helpers in Bodu.Extensions build on it.
Key types
- DateTimeFormatInfoExtensions - one method,
LastDayOfWeek(this DateTimeFormatInfo), which returns the day six days after the culture'sFirstDayOfWeek: Sunday for a Monday-first culture, Saturday for a Sunday-first one.
Example
using System.Globalization;
using Bodu.Globalization.Extensions;
DateTimeFormatInfo enGb = CultureInfo.GetCultureInfo("en-GB").DateTimeFormat;
DayOfWeek first = enGb.FirstDayOfWeek; // Monday - BCL property
DayOfWeek last = enGb.LastDayOfWeek(); // Sunday - Bodu extension
Notes
- Companion namespace. The broader date / time / culture surface - first and last date of the week, ISO week numbering, working-week tests - lives in DateTimeExtensions and DateOnlyExtensions; day-of-week sets are modelled by WeekPattern and WorkingDaysOfWeek.
- See also: the Bodu.Core introduction, Bodu.Extensions.
Classes
- DateTimeFormatInfoExtensions
Provides culture-aware calendar lookups against DateTimeFormatInfo that derive week-structure values which the BCL exposes only indirectly.