You need to get the DateTimeFormatInfo
of the culture you're working with, then modify the array of strings called AbbreviatedDayNames
. After that, ddd
will return Th
for you.
http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.abbreviateddaynames(VS.71).aspx
DateTimeFormatInfo.AbbreviatedDayNames
Gets or sets a one-dimensional array
of type String containing the
culture-specific abbreviated names of
the days of the week.
Here's a sample of how to do it:
class Program
{
static void Main()
{
var dtInfo = new System.Globalization.DateTimeFormatInfo();
Console.WriteLine("Old array of abbreviated dates:");
var dt = DateTime.Today;
for (int i = 0; i < 7; i++)
{
Console.WriteLine(dt.AddDays(i).ToString("ddd", dtInfo));
}
// change the short weekday names array
var newWeekDays =
new string[] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
dtInfo.AbbreviatedDayNames = newWeekDays;
Console.WriteLine("New array of abbreviated dates:");
for (int i = 0; i < 7; i++)
{
Console.WriteLine(dt.AddDays(i).ToString("ddd", dtInfo));
}
Console.ReadLine();
}
}
One more note: of course, if you are constrained from providing the IFormatProvider
, then you can override the current thread's CultureInfo
, for example:
CultureInfo customCulture = CultureInfo.CreateSpecificCulture("en-US");
// ... set up the DateTimeFormatInfo, etc...
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
More on CurrentCulture:
http://msdn.microsoft.com/en-us/library/system.threading.thread.currentuiculture.aspx
Thread.CurrentUICulture
Property
Gets or sets the
current culture used by the Resource
Manager to look up culture-specific
resources at run time.