Table of Contents

Bodu.Globalization.Extensions Namespace

Package
Bodu.Core 1.0.1

Bodu.Core

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's FirstDayOfWeek: 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

Classes

DateTimeFormatInfoExtensions

Provides culture-aware calendar lookups against DateTimeFormatInfo that derive week-structure values which the BCL exposes only indirectly.