We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
-
Expand
Microsoft.Win32
-
Expand
Microsoft.Win32.SafeHandles
-
Expand
System
-
Expand
System.Runtime.Hosting
-
Expand
System.Runtime.InteropServices
-
Expand
System.Runtime.CompilerServices
-
Expand
System.Collections
-
Expand
System.Collections.Generic
-
Expand
System.Collections.ObjectModel
-
Expand
System.Configuration.Assemblies
-
Expand
System.Diagnostics
-
Expand
System.Diagnostics.CodeAnalysis
-
Expand
System.Diagnostics.SymbolStore
-
Expand
System.Globalization
-
Expand
__DateBuffer
-
Expand
BaseInfoTable
-
Expand
BidiCategory
-
Expand
Calendar
-
Expand
CalendarAlgorithmType
-
Expand
CalendarId
-
Expand
CalendarTable
-
Expand
CalendarTableData
-
Expand
CalendarWeekRule
-
Expand
CharUnicodeInfo
-
Expand
ChineseLunisolarCalendar
-
Expand
CodePageDataItem
-
Expand
CompareInfo
-
Expand
CompareOptions
-
Expand
CultureData
-
Expand
CultureFlags
-
Expand
CultureInfo
-
Expand
CultureNameOffsetItem
-
Expand
CultureTable
-
Expand
CultureTableData
-
Expand
CultureTableHeader
-
Expand
CultureTableItem
-
Expand
CultureTableRecord
-
Expand
CultureTypes
-
Expand
DateMapping
-
Expand
DateTimeFormatFlags
-
Expand
DateTimeFormatInfo
-
AbbreviatedDayNames()
-
AbbreviatedEnglishEraNames()
-
AbbreviatedEraNames()
-
AbbreviatedMonthGenitiveNames()
-
AbbreviatedMonthNames()
-
AddDefaultFormat(string, string)
-
AddMonthNames(TokenHashValue, string)
-
AMDesignator()
-
Calendar()
-
CalendarIdToCultureId(int)
-
CalendarWeekRule()
-
CheckNullValue(string, int)
-
ClearTokenHashTable(bool)
-
Clone()
-
ClonedAllLongDatePatterns()
-
ClonedAllLongTimePatterns()
-
ClonedAllShortDatePatterns()
-
ClonedAllShortTimePatterns()
-
ClonedAllYearMonthPatterns()
-
CompareInfo()
-
CreateTokenHashTable()
-
CultureId()
-
CultureName()
-
CurrentInfo()
-
DateSeparator()
-
DateTimeFormatInfo()
-
DateTimeFormatInfo(CultureTableRecord, int, Calendar)
-
DateWords()
-
DayNames()
-
EraNames()
-
FirstDayOfWeek()
-
FormatFlags()
-
FullDateTimePattern()
-
GeneralLongTimePattern()
-
GeneralShortTimePattern()
-
GetAbbreviatedDayName(DayOfWeek)
-
GetAbbreviatedDayOfWeekNames()
-
GetAbbreviatedEraName(int)
-
GetAbbreviatedMonthName(int)
-
GetAbbreviatedMonthNames()
-
GetAllDateTimePatterns()
-
GetAllDateTimePatterns(char)
-
GetCalendarInfo(int, int, int)
-
GetCalendarNativeNameFallback(int)
-
GetCombinedPatterns(string, string, string)
-
GetDayName(DayOfWeek)
-
GetDayOfWeekNames()
-
GetEra(string)
-
GetEraName(int)
-
GetFormat(Type)
-
GetInstance(IFormatProvider)
-
GetJapaneseCalendarDTFI()
-
GetLongDatePattern(int)
-
GetMonthName(int)
-
GetMonthNames()
-
GetShortDatePattern(int)
-
GetShortestDayName(DayOfWeek)
-
GetTaiwanCalendarDTFI()
-
GetYearMonthPattern(int)
-
HasForceTwoDigitYears()
-
HasSpacesInDayNames()
-
HasSpacesInMonthNames()
-
HasYearMonthAdjustment()
-
InitializeOverridableProperties()
-
InsertAtCurrentHashNode(TokenHashValue, string, char, TokenType, int, int, int, int)
-
InsertHash(TokenHashValue, string, TokenType, int)
-
internalGetGenitiveMonthNames(bool)
-
internalGetLeapYearMonthNames()
-
internalGetMonthName(int, MonthNameStyles, bool)
-
internalGetSuperShortDayNames()
-
InternalSyncObject()
-
InvariantInfo()
-
IsHebrewChar(char)
-
IsReadOnly()
-
LanguageName()
-
LongDatePattern()
-
LongTimePattern()
-
MonthDayPattern()
-
MonthGenitiveNames()
-
MonthNames()
-
NativeCalendarName()
-
OnDeserialized(StreamingContext)
-
OnSerializing(StreamingContext)
-
OptionalCalendars()
-
PMDesignator()
-
ReadOnly(DateTimeFormatInfo)
-
RFC1123Pattern()
-
SetAllDateTimePatterns(string, char)
-
SetDefaultPatternAsFirstItem(string, string)
-
ShortDatePattern()
-
ShortestDayNames()
-
ShortTimePattern()
-
SortableDateTimePattern()
-
TimeSeparator()
-
Tokenize(TokenType, TokenType, int, __DTString)
-
TryParseHebrewNumber(__DTString, bool, int)
-
UniversalSortableDateTimePattern()
-
ValidateStyles(DateTimeStyles, string)
-
VerifyWritable()
-
YearMonthAdjustment(int, int, bool)
-
YearMonthPattern()
-
Expand
DateTimeFormatInfoScanner
-
Expand
DateTimeStyles
-
Expand
DaylightTime
-
Expand
DigitShapes
-
Expand
DigitValues
-
Expand
DTFIUserOverrideValues
-
Expand
EastAsianLunisolarCalendar
-
Expand
EncodingTable
-
Expand
EndianessHeader
-
Expand
EraInfo
-
Expand
ExceptionTableItem
-
Expand
FORMATFLAGS
-
Expand
FoundDatePattern
-
Expand
GlobalizationAssembly
-
Expand
GregorianCalendar
-
Expand
GregorianCalendarHelper
-
Expand
GregorianCalendarTypes
-
Expand
HebrewCalendar
-
Expand
HebrewNumber
-
Expand
HebrewNumberParsingContext
-
Expand
HebrewNumberParsingState
-
Expand
HebrewToken
-
Expand
HebrewValue
-
Expand
HijriCalendar
-
Expand
HS
-
Expand
IdnMapping
-
Expand
IDOffsetItem
-
Expand
IetfNameOffsetItem
-
Expand
InternalCodePageDataItem
-
Expand
InternalEncodingDataItem
-
Expand
JapaneseCalendar
-
Expand
JapaneseLunisolarCalendar
-
Expand
JulianCalendar
-
Expand
KoreanCalendar
-
Expand
KoreanLunisolarCalendar
-
Expand
MemoryMapFile
-
Expand
MonthNameStyles
-
Expand
NumberFormatInfo
-
Expand
NumberStyles
-
Expand
PersianCalendar
-
Expand
RegionInfo
-
Expand
RegionNameOffsetItem
-
Expand
SortKey
-
Expand
StringInfo
-
Expand
TaiwanCalendar
-
Expand
TaiwanLunisolarCalendar
-
Expand
TextElementEnumerator
-
Expand
TextInfo
-
Expand
TextInfoDataHeader
-
Expand
ThaiBuddhistCalendar
-
Expand
TokenHashValue
-
Expand
UmAlQuraCalendar
-
Expand
UnicodeCategory
-
Expand
UnicodeDataHeader
-
Expand
System.IO
-
Expand
System.IO.IsolatedStorage
-
Expand
System.Reflection
-
Expand
System.Reflection.Cache
-
Expand
System.Reflection.Emit
-
Expand
System.Resources
-
Expand
System.Runtime
-
Expand
System.Runtime.InteropServices.Expando
-
Expand
System.Runtime.ConstrainedExecution
-
Expand
System.Runtime.Remoting.Activation
-
Expand
System.Runtime.Remoting.Messaging
-
Expand
System.Runtime.Remoting.Channels
-
Expand
System.Runtime.Remoting.Lifetime
-
Expand
System.Runtime.Remoting
-
Expand
System.Runtime.Remoting.Contexts
-
Expand
System.Runtime.Remoting.Proxies
-
Expand
System.Runtime.Remoting.Metadata
-
Expand
System.Runtime.Remoting.Metadata.W3cXsd2001
-
Expand
System.Runtime.Remoting.Services
-
Expand
System.Runtime.Serialization
-
Expand
System.Runtime.Serialization.Formatters
-
Expand
System.Runtime.Serialization.Formatters.Binary
-
Expand
System.Runtime.Versioning
-
Expand
System.Security
-
Expand
System.Security.Cryptography
-
Expand
System.Security.Cryptography.X509Certificates
-
Expand
System.Security.Permissions
-
Expand
System.Security.Policy
-
Expand
System.Security.Principal
-
Expand
System.Security.Util
-
Expand
System.Text
-
Expand
System.Threading
-
Expand
System.Runtime.Remoting.Channels.Http
-
Expand
System.Runtime.Remoting.Channels.Tcp
-
Expand
System.Runtime.Remoting.MetadataServices
-
Expand
System.Runtime.Serialization.Formatters.Soap.Xml
-
Expand
System.Runtime.Serialization.Formatters.Soap
-
Expand
Microsoft.Tools.Caspol
-
Expand
Microsoft.Tools.Build
-
Expand
Microsoft.CSharp
-
Expand
System.CodeDom
-
Expand
System.CodeDom.Compiler
-
Expand
System.Collections.Specialized
-
Expand
System.ComponentModel
-
Expand
System.ComponentModel.Design
-
Expand
System.ComponentModel.Design.Serialization
-
Expand
System.Configuration
-
Expand
System.Web
-
Expand
System.Configuration.Provider
-
Expand
System.Configuration.Internal
-
Expand
System.Internal
-
Expand
System.Windows.Forms
-
Expand
System.Net
-
Expand
System.Net.Sockets
-
Expand
System.Net.NetworkInformation
-
Expand
System.Net.ComImports
-
Expand
System.Net.Security
-
Expand
System.Net.Cache
-
Expand
System.Net.Configuration
-
Expand
System.Text.RegularExpressions
-
Expand
System.Tools
-
Expand
System.IO.Compression
-
Expand
System.IO.Ports
-
Expand
System.Security.AccessControl
-
Expand
System.Xml
-
Expand
System.Xml.XPath.DataBinding
-
Expand
System.Xml.Schema
-
Expand
System.Xml.Serialization
-
Expand
System.Xml.Serialization.Advanced
-
Expand
System.Xml.Serialization.Configuration
-
Expand
System.Xml.XPath
-
Expand
System.Xml.Xsl
-
Expand
System.Xml.Xsl.IlGen
-
Expand
System.Xml.Xsl.Qil
-
Expand
System.Xml.Xsl.Runtime
-
Expand
System.Xml.Xsl.XPath
-
Expand
System.Xml.Xsl.Xslt
-
Expand
System.Xml.Xsl.XsltOld
-
Expand
System.Xml.Xsl.XsltOld.Debugger
-
Expand
Microsoft.JScript
-
Expand
Microsoft.Vsa
-
Expand
Microsoft.JScript.Vsa
- namespace System.Globalization
- {
- using System;
- using System.Security;
- using System.Threading;
- using System.Collections;
- using System.Runtime.Serialization;
- using System.Security.Permissions;
- using System.Runtime.InteropServices;
- using System.Text;
-
-
-
-
-
-
-
-
-
- [Flags()]
- internal enum MonthNameStyles
- {
- Regular = 0,
- Genitive = 1,
- LeapYear = 2
- }
-
-
-
-
-
-
-
-
-
-
- [Flags()]
- internal enum DateTimeFormatFlags
- {
- None = 0,
- UseGenitiveMonth = 1,
- UseLeapYearMonth = 2,
- UseSpacesInMonthNames = 4,
-
- UseHebrewRule = 8,
-
- UseSpacesInDayNames = 16,
-
- UseDigitPrefixInTokens = 32,
-
- NotInitialized = -1
- }
-
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider
- {
-
-
-
- private static DateTimeFormatInfo invariantInfo;
-
-
- [NonSerialized()]
- internal CultureTableRecord m_cultureTableRecord;
-
-
- [OptionalField(VersionAdded = 2)]
- internal string m_name = null;
-
-
- [NonSerialized()]
- internal string m_langName = null;
-
-
- [NonSerialized()]
- internal CompareInfo m_compareInfo = null;
-
-
-
- internal bool m_isDefaultCalendar;
-
- internal int CultureId {
- get { return this.m_cultureTableRecord.CultureID; }
- }
-
-
-
-
-
-
- internal bool bUseCalendarInfo = false;
-
-
-
-
- internal string amDesignator = null;
- internal string pmDesignator = null;
- internal string dateSeparator = null;
- internal string longTimePattern = null;
- internal string shortTimePattern = null;
- internal string generalShortTimePattern = null;
- internal string generalLongTimePattern = null;
- internal string timeSeparator = null;
- internal string monthDayPattern = null;
-
-
-
-
- internal string[] allShortTimePatterns = null;
- internal string[] allLongTimePatterns = null;
-
-
-
-
- internal const string rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
-
- internal const string sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
- internal const string universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'";
-
-
-
-
- internal Calendar calendar = null;
-
- internal int firstDayOfWeek = -1;
- internal int calendarWeekRule = -1;
-
- internal string fullDateTimePattern = null;
-
- internal string longDatePattern = null;
-
- internal string shortDatePattern = null;
-
- internal string yearMonthPattern = null;
-
- internal string[] abbreviatedDayNames = null;
-
- [OptionalField(VersionAdded = 2)]
- internal string[] m_superShortDayNames = null;
-
- internal string[] dayNames = null;
- internal string[] abbreviatedMonthNames = null;
- internal string[] monthNames = null;
-
- [OptionalField(VersionAdded = 2)]
- internal string[] genitiveMonthNames = null;
-
-
- [OptionalField(VersionAdded = 2)]
- internal string[] m_genitiveAbbreviatedMonthNames = null;
-
-
- [OptionalField(VersionAdded = 2)]
- internal string[] leapYearMonthNames = null;
-
-
-
-
-
- [NonSerialized()]
-
- internal string[] allYearMonthPatterns = null;
- internal string[] allShortDatePatterns = null;
- internal string[] allLongDatePatterns = null;
-
-
-
-
- internal string[] m_eraNames = null;
- internal string[] m_abbrevEraNames = null;
- internal string[] m_abbrevEnglishEraNames = null;
-
- internal string[] m_dateWords = null;
-
- internal int[] optionalCalendars = null;
-
- private const int DEFAULT_ALL_DATETIMES_SIZE = 132;
-
- internal bool m_isReadOnly = false;
-
-
- [OptionalField(VersionAdded = 2)]
- internal DateTimeFormatFlags formatFlags = DateTimeFormatFlags.NotInitialized;
-
- private static Hashtable m_calendarNativeNames;
-
- private static object s_InternalSyncObject;
-
- private static object InternalSyncObject {
- get {
- if (s_InternalSyncObject == null) {
- object o = new object();
- Interlocked.CompareExchange(ref s_InternalSyncObject, o, null);
- }
- return s_InternalSyncObject;
- }
- }
-
- internal string CultureName {
- get {
- if (m_name == null) {
- m_name = this.m_cultureTableRecord.SNAME;
- }
- return (m_name);
- }
- }
-
- internal string LanguageName {
- get {
- if (m_langName == null) {
- m_langName = this.m_cultureTableRecord.SISO639LANGNAME;
- }
- return (m_langName);
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////////
-
- private string[] GetAbbreviatedDayOfWeekNames()
- {
- if (abbreviatedDayNames == null) {
- if (abbreviatedDayNames == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.GetAbbreviatedDayOfWeekNames] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SABBREVDAYNAMES(Calendar.ID);
- }
- if (temp == null || temp.Length == 0 || temp[0].Length == 0)
- temp = this.m_cultureTableRecord.SABBREVDAYNAMES;
- System.Threading.Thread.MemoryBarrier();
- abbreviatedDayNames = temp;
- BCLDebug.Assert(abbreviatedDayNames.Length == 7, "[DateTimeFormatInfo.GetAbbreviatedDayOfWeekNames] Expected 7 day names in a week");
- }
- }
- return (abbreviatedDayNames);
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
- private string[] internalGetSuperShortDayNames()
- {
- if (this.m_superShortDayNames == null) {
- if (this.m_superShortDayNames == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.internalGetSuperShortDayNames] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SSUPERSHORTDAYNAMES(Calendar.ID);
- }
- if (temp == null || temp.Length == 0 || temp[0].Length == 0)
- temp = this.m_cultureTableRecord.SSUPERSHORTDAYNAMES;
- System.Threading.Thread.MemoryBarrier();
- this.m_superShortDayNames = temp;
- BCLDebug.Assert(this.m_superShortDayNames.Length == 7, "[DateTimeFormatInfo.internalGetSuperShortDayNames] Expected 7 day names in a week");
- }
- }
- return (this.m_superShortDayNames);
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////////
-
- private string[] GetDayOfWeekNames()
- {
- if (dayNames == null) {
- if (dayNames == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.GetDayOfWeekNames] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SDAYNAMES(Calendar.ID);
- }
- if (temp == null || temp.Length == 0 || temp[0].Length == 0)
- temp = this.m_cultureTableRecord.SDAYNAMES;
- System.Threading.Thread.MemoryBarrier();
- dayNames = temp;
- BCLDebug.Assert(dayNames.Length == 7, "[DateTimeFormatInfo.GetDayOfWeekNames] Expected 7 day names in a week");
- }
- }
- return (dayNames);
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////////
-
- private string[] GetAbbreviatedMonthNames()
- {
- if (abbreviatedMonthNames == null) {
- if (abbreviatedMonthNames == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.GetAbbreviatedMonthNames] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SABBREVMONTHNAMES(Calendar.ID);
- }
- if (temp == null || temp.Length == 0 || temp[0].Length == 0)
- temp = this.m_cultureTableRecord.SABBREVMONTHNAMES;
- System.Threading.Thread.MemoryBarrier();
- abbreviatedMonthNames = temp;
- BCLDebug.Assert(abbreviatedMonthNames.Length == 12 || abbreviatedMonthNames.Length == 13, "[DateTimeFormatInfo.GetAbbreviatedMonthNames] Expected 12 or 13 month names in a year");
- }
- }
- return (abbreviatedMonthNames);
- }
-
-
- ////////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////////
-
- private string[] GetMonthNames()
- {
- if (monthNames == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.GetMonthNames] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SMONTHNAMES(Calendar.ID);
- }
- if (temp == null || temp.Length == 0 || temp[0].Length == 0)
- temp = this.m_cultureTableRecord.SMONTHNAMES;
- System.Threading.Thread.MemoryBarrier();
- monthNames = temp;
- BCLDebug.Assert(MonthNames.Length == 12 || MonthNames.Length == 13, "[DateTimeFormatInfo.GetMonthNames] Expected 12 or 13 month names in a year");
- }
-
- return (monthNames);
- }
-
-
- public DateTimeFormatInfo()
- {
-
-
-
- this.m_cultureTableRecord = CultureInfo.InvariantCulture.m_cultureTableRecord;
-
-
- this.m_isDefaultCalendar = true;
- this.calendar = GregorianCalendar.GetDefaultInstance();
-
-
-
- InitializeOverridableProperties();
- }
-
- internal DateTimeFormatInfo(CultureTableRecord cultureTable, int cultureID, Calendar cal)
- {
- this.m_cultureTableRecord = cultureTable;
-
- this.Calendar = cal;
- }
-
- #region Serialization
-
- private int CultureID;
- private bool m_useUserOverride;
- private int nDataItem;
-
- [OnDeserialized()]
- private void OnDeserialized(StreamingContext ctx)
- {
- BCLDebug.Assert(CultureID >= 0, "[DateTimeFormatInfo.OnDeserialized] clulture ID < 0");
-
- if (CultureTableRecord.IsCustomCultureId(CultureID))
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(m_name, m_useUserOverride);
- else
- m_cultureTableRecord = CultureTableRecord.GetCultureTableRecord(CultureID, m_useUserOverride);
-
- if (calendar == null) {
- calendar = (Calendar)GregorianCalendar.GetDefaultInstance().Clone();
- calendar.SetReadOnlyState(m_isReadOnly);
- }
- else {
- CultureInfo.CheckDomainSafetyObject(calendar, this);
- }
-
- InitializeOverridableProperties();
- }
-
- [OnSerializing()]
- private void OnSerializing(StreamingContext ctx)
- {
- CultureID = m_cultureTableRecord.CultureID;
- m_useUserOverride = m_cultureTableRecord.UseUserOverride;
- nDataItem = m_cultureTableRecord.EverettDataItem();
-
-
-
-
-
-
- if (CultureTableRecord.IsCustomCultureId(CultureID)) {
-
- m_name = this.CultureName;
- }
- }
- #endregion Serialization
-
-
-
-
-
-
- public static DateTimeFormatInfo InvariantInfo {
- get {
- if (invariantInfo == null) {
- DateTimeFormatInfo info = new DateTimeFormatInfo();
- info.Calendar.SetReadOnlyState(true);
- info.m_isReadOnly = true;
- invariantInfo = info;
- }
- return (invariantInfo);
- }
- }
-
-
-
-
- public static DateTimeFormatInfo CurrentInfo {
- get {
- System.Globalization.CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture;
- if (!culture.m_isInherited) {
- DateTimeFormatInfo info = culture.dateTimeInfo;
- if (info != null) {
- return info;
- }
- }
- return (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo));
- }
- }
-
-
- public static DateTimeFormatInfo GetInstance(IFormatProvider provider)
- {
-
- DateTimeFormatInfo info;
- CultureInfo cultureProvider = provider as CultureInfo;
- if (cultureProvider != null && !cultureProvider.m_isInherited) {
- info = cultureProvider.dateTimeInfo;
- if (info != null) {
- return info;
- }
- else {
- return cultureProvider.DateTimeFormat;
- }
- }
-
- info = provider as DateTimeFormatInfo;
- if (info != null) {
- return info;
- }
- if (provider != null) {
- info = provider.GetFormat(typeof(DateTimeFormatInfo)) as DateTimeFormatInfo;
- if (info != null) {
- return info;
- }
- }
- return CurrentInfo;
- }
-
-
- public object GetFormat(Type formatType)
- {
- return (formatType == typeof(DateTimeFormatInfo) ? this : null);
- }
-
-
- public object Clone()
- {
- DateTimeFormatInfo n = (DateTimeFormatInfo)MemberwiseClone();
-
-
- n.calendar = (Calendar)this.Calendar.Clone();
- n.m_isReadOnly = false;
- return n;
- }
-
-
- public string AMDesignator {
- get {
- BCLDebug.Assert(amDesignator != null, "DateTimeFormatInfo.AMDesignator, amDesignator != null");
- return (amDesignator);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- ClearTokenHashTable(true);
- amDesignator = value;
- }
- }
-
- private void InitializeOverridableProperties()
- {
-
-
- if (amDesignator == null) {
- amDesignator = m_cultureTableRecord.S1159;
- }
- if (pmDesignator == null) {
- pmDesignator = m_cultureTableRecord.S2359;
- }
- if (longTimePattern == null) {
- longTimePattern = m_cultureTableRecord.STIMEFORMAT;
- }
- if (firstDayOfWeek == -1) {
- firstDayOfWeek = m_cultureTableRecord.IFIRSTDAYOFWEEK;
- }
- if (calendarWeekRule == -1) {
- calendarWeekRule = m_cultureTableRecord.IFIRSTWEEKOFYEAR;
- }
-
-
- if (yearMonthPattern == null) {
- yearMonthPattern = GetYearMonthPattern(calendar.ID);
- }
- if (shortDatePattern == null) {
- shortDatePattern = GetShortDatePattern(calendar.ID);
- }
- if (longDatePattern == null) {
- longDatePattern = GetLongDatePattern(calendar.ID);
- }
- }
-
-
- public Calendar Calendar {
- get {
- BCLDebug.Assert(calendar != null, "DateTimeFormatInfo.Calendar: calendar != null");
- return (calendar);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Obj"));
- }
- if (value == calendar) {
- return;
- }
-
-
-
-
-
- CultureInfo.CheckDomainSafetyObject(value, this);
-
- for (int i = 0; i < OptionalCalendars.Length; i++) {
- if (OptionalCalendars[i] == value.ID) {
- ClearTokenHashTable(false);
-
-
-
- m_isDefaultCalendar = (value.ID == Calendar.CAL_GREGORIAN);
-
-
-
- if (calendar != null) {
-
-
-
-
-
- m_eraNames = null;
- m_abbrevEraNames = null;
- m_abbrevEnglishEraNames = null;
-
- shortDatePattern = null;
- yearMonthPattern = null;
- monthDayPattern = null;
- longDatePattern = null;
-
- dayNames = null;
- abbreviatedDayNames = null;
- m_superShortDayNames = null;
- monthNames = null;
- abbreviatedMonthNames = null;
- genitiveMonthNames = null;
- m_genitiveAbbreviatedMonthNames = null;
- leapYearMonthNames = null;
- formatFlags = DateTimeFormatFlags.NotInitialized;
-
-
- fullDateTimePattern = null;
- generalShortTimePattern = null;
- generalLongTimePattern = null;
- allShortDatePatterns = null;
- allLongDatePatterns = null;
- allYearMonthPatterns = null;
-
-
- }
-
- calendar = value;
-
- if (this.m_cultureTableRecord.UseCurrentCalendar(value.ID)) {
-
-
-
-
-
-
-
- DTFIUserOverrideValues temp = new DTFIUserOverrideValues();
-
-
-
-
-
-
- m_cultureTableRecord.GetDTFIOverrideValues(ref temp);
-
-
- amDesignator = temp.amDesignator;
- pmDesignator = temp.pmDesignator;
- longTimePattern = temp.longTimePattern;
- firstDayOfWeek = (int)temp.firstDayOfWeek;
- calendarWeekRule = (int)temp.calendarWeekRule;
- shortDatePattern = temp.shortDatePattern;
- longDatePattern = temp.longDatePattern;
- yearMonthPattern = temp.yearMonthPattern;
-
-
-
-
-
-
-
- if (yearMonthPattern == null || yearMonthPattern.Length == 0) {
- yearMonthPattern = GetYearMonthPattern(value.ID);
- }
-
- }
- else {
-
-
- InitializeOverridableProperties();
- }
- return;
- }
- }
-
- throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("Argument_InvalidCalendar"));
- }
- }
-
- internal int[] OptionalCalendars {
- get {
- if (optionalCalendars == null) {
- optionalCalendars = this.m_cultureTableRecord.IOPTIONALCALENDARS;
- }
- return (optionalCalendars);
- }
- }
-
-
-
-
- public int GetEra(string eraName)
- {
- if (eraName == null) {
- throw new ArgumentNullException("eraName", Environment.GetResourceString("ArgumentNull_String"));
- }
-
-
-
-
-
-
-
- for (int i = 0; i < EraNames.Length; i++) {
-
- if (m_eraNames[i].Length > 0) {
- if (String.Compare(eraName, m_eraNames[i], true, CultureInfo.CurrentCulture) == 0) {
- return (i + 1);
- }
- }
- }
- for (int i = 0; i < AbbreviatedEraNames.Length; i++) {
- if (String.Compare(eraName, m_abbrevEraNames[i], true, CultureInfo.CurrentCulture) == 0) {
- return (i + 1);
- }
- }
- for (int i = 0; i < AbbreviatedEnglishEraNames.Length; i++) {
-
-
- if (String.Compare(eraName, m_abbrevEnglishEraNames[i], true, CultureInfo.InvariantCulture) == 0) {
- return (i + 1);
- }
- }
- return (-1);
- }
-
- internal string[] EraNames {
- get {
- if (m_eraNames == null) {
- if (Calendar.ID == Calendar.CAL_GREGORIAN) {
-
-
- m_eraNames = new string[1] {this.m_cultureTableRecord.SADERA};
- }
- else if (Calendar.ID != Calendar.CAL_TAIWAN) {
-
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.EraNames] Expected Calendar.ID > 0");
- m_eraNames = CalendarTable.Default.SERANAMES(Calendar.ID);
- }
- else {
-
-
- m_eraNames = new string[] {CalendarTable.nativeGetEraName(1028, Calendar.ID)};
- }
- }
- return (m_eraNames);
- }
- }
-
-
-
-
- public string GetEraName(int era)
- {
- if (era == Calendar.CurrentEra) {
- era = Calendar.CurrentEraValue;
- }
-
-
-
-
- if ((--era) < EraNames.Length && (era >= 0)) {
- return (m_eraNames[era]);
- }
- throw new ArgumentOutOfRangeException("era", Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue"));
- }
-
- internal string[] AbbreviatedEraNames {
- get {
- if (m_abbrevEraNames == null) {
- if (Calendar.ID == Calendar.CAL_TAIWAN) {
- string twnEra = GetEraName(1);
- if (twnEra.Length > 0) {
- if (twnEra.Length == 4) {
-
-
- m_abbrevEraNames = new string[] {twnEra.Substring(2, 2)};
- }
- else {
-
- m_abbrevEraNames = new string[] {twnEra};
- }
- }
- else {
-
- m_abbrevEraNames = new string[0];
- }
- }
- else {
- if (Calendar.ID == Calendar.CAL_GREGORIAN) {
-
-
- m_abbrevEraNames = new string[1] {this.m_cultureTableRecord.SABBREVADERA};
- }
- else {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AbbreviatedEraNames] Expected Calendar.ID > 0");
- m_abbrevEraNames = CalendarTable.Default.SABBREVERANAMES(Calendar.ID);
- }
- }
- }
- return (m_abbrevEraNames);
- }
- }
-
-
- public string GetAbbreviatedEraName(int era)
- {
- if (AbbreviatedEraNames.Length == 0) {
-
-
- return (GetEraName(era));
- }
- if (era == Calendar.CurrentEra) {
- era = Calendar.CurrentEraValue;
- }
- if ((--era) < m_abbrevEraNames.Length && (era >= 0)) {
- return (m_abbrevEraNames[era]);
- }
- throw new ArgumentOutOfRangeException("era", Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue"));
- }
-
- internal string[] AbbreviatedEnglishEraNames {
- get {
- if (m_abbrevEnglishEraNames == null) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AbbreviatedEnglishEraNames] Expected Calendar.ID > 0");
- m_abbrevEnglishEraNames = CalendarTable.Default.SABBREVENGERANAMES(Calendar.ID);
- }
- return (m_abbrevEnglishEraNames);
- }
- }
-
-
- public string DateSeparator {
- get {
- if (dateSeparator == null) {
- dateSeparator = this.m_cultureTableRecord.SDATE;
- }
- return (dateSeparator);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- ClearTokenHashTable(true);
- dateSeparator = value;
- }
- }
-
-
- public DayOfWeek FirstDayOfWeek {
- get { return ((DayOfWeek)firstDayOfWeek); }
-
- set {
- VerifyWritable();
- if (value >= DayOfWeek.Sunday && value <= DayOfWeek.Saturday) {
- firstDayOfWeek = (int)value;
- }
- else {
- throw new ArgumentOutOfRangeException("value", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), DayOfWeek.Sunday, DayOfWeek.Saturday));
- }
- }
- }
-
-
- public CalendarWeekRule CalendarWeekRule {
- get { return ((CalendarWeekRule)this.calendarWeekRule); }
-
- set {
- VerifyWritable();
- if (value >= CalendarWeekRule.FirstDay && value <= CalendarWeekRule.FirstFourDayWeek) {
- calendarWeekRule = (int)value;
- }
- else {
- throw new ArgumentOutOfRangeException("value", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), CalendarWeekRule.FirstDay, CalendarWeekRule.FirstFourDayWeek));
- }
- }
- }
-
-
-
- public string FullDateTimePattern {
- get {
- if (fullDateTimePattern == null) {
- fullDateTimePattern = LongDatePattern + " " + LongTimePattern;
- }
- return (fullDateTimePattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- fullDateTimePattern = value;
- }
- }
-
- private string GetLongDatePattern(int calID)
- {
- string strTemp = String.Empty;
- if (!m_isDefaultCalendar) {
-
- BCLDebug.Assert(calID > 1, "[DateTimeFormatInfo.LongDatePattern] Expected calID > 1");
- strTemp = CalendarTable.Default.SLONGDATE(calID)[0];
-
- BCLDebug.Assert(strTemp.Length != 0, "Calendar.nlp should have SLONGDATE value");
- }
- else {
- strTemp = this.m_cultureTableRecord.SLONGDATE;
- }
- return (strTemp);
- }
-
-
- public string LongDatePattern {
- get {
- BCLDebug.Assert(longDatePattern != null, "DateTimeFormatInfo.LongDatePattern, longDatePattern != null");
- return (longDatePattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- ClearTokenHashTable(true);
-
- SetDefaultPatternAsFirstItem(allLongDatePatterns, value);
- longDatePattern = value;
-
- fullDateTimePattern = null;
- }
- }
-
-
- public string LongTimePattern {
- get {
-
- BCLDebug.Assert(longTimePattern != null, "DateTimeFormatInfo.LongTimePattern, longTimePattern != null");
- return (longTimePattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
-
- longTimePattern = value;
-
- fullDateTimePattern = null;
-
- generalLongTimePattern = null;
-
- }
- }
-
-
-
- public string MonthDayPattern {
- get {
- if (monthDayPattern == null) {
-
-
- string strTemp;
- if (m_isDefaultCalendar) {
- strTemp = this.m_cultureTableRecord.SMONTHDAY;
- }
- else {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.GetStringFromTable] Expected Calendar.ID > 0");
- strTemp = CalendarTable.Default.SMONTHDAY(Calendar.ID);
-
- if (strTemp.Length == 0)
- strTemp = this.m_cultureTableRecord.SMONTHDAY;
- }
- monthDayPattern = strTemp;
- }
- return (monthDayPattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- monthDayPattern = value;
- }
- }
-
-
- public string PMDesignator {
- get {
- BCLDebug.Assert(pmDesignator != null, "DateTimeFormatInfo.PMDesignator, pmDesignator != null");
- return (pmDesignator);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- ClearTokenHashTable(true);
- pmDesignator = value;
- }
- }
-
-
-
- public string RFC1123Pattern {
- get { return (rfc1123Pattern); }
- }
-
- internal string GetShortDatePattern(int calID)
- {
- string strTemp = String.Empty;
- if (!m_isDefaultCalendar) {
-
- BCLDebug.Assert(calID > 1, "[DateTimeFormatInfo.ShortDatePattern] Expected calID > 1");
- strTemp = CalendarTable.Default.SSHORTDATE(calID)[0];
-
- BCLDebug.Assert(strTemp.Length != 0, "Calendar.nlp should have SHORTDATE value");
- }
- else {
- strTemp = this.m_cultureTableRecord.SSHORTDATE;
- }
- return (strTemp);
- }
-
-
- public string ShortDatePattern {
- get {
- BCLDebug.Assert(shortDatePattern != null, "DateTimeFormatInfo.ShortDatePattern, shortDatePattern != null");
- return (shortDatePattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
-
- SetDefaultPatternAsFirstItem(allShortDatePatterns, value);
- shortDatePattern = value;
-
- generalLongTimePattern = null;
- generalShortTimePattern = null;
- }
- }
-
-
- public string ShortTimePattern {
- get {
- if (shortTimePattern == null) {
- shortTimePattern = this.m_cultureTableRecord.SSHORTTIME;
- }
- return (shortTimePattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- shortTimePattern = value;
-
- generalShortTimePattern = null;
-
- }
- }
-
-
- public string SortableDateTimePattern {
- get { return (sortableDateTimePattern); }
- }
-
-
-
- internal string GeneralShortTimePattern {
- get {
- if (generalShortTimePattern == null) {
- generalShortTimePattern = ShortDatePattern + " " + ShortTimePattern;
- }
- return (generalShortTimePattern);
- }
- }
-
-
-
- internal string GeneralLongTimePattern {
- get {
- if (generalLongTimePattern == null) {
- generalLongTimePattern = ShortDatePattern + " " + LongTimePattern;
- }
- return (generalLongTimePattern);
- }
- }
-
-
- public string TimeSeparator {
- get {
- if (timeSeparator == null) {
- timeSeparator = this.m_cultureTableRecord.STIME;
- }
- return (timeSeparator);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- ClearTokenHashTable(true);
- timeSeparator = value;
- }
- }
-
-
-
- public string UniversalSortableDateTimePattern {
- get { return (universalSortableDateTimePattern); }
- }
-
- private string GetYearMonthPattern(int calID)
- {
- string result = null;
- if (!m_isDefaultCalendar) {
-
-
- BCLDebug.Assert(calID > 1, "[DateTimeFormatInfo.YearMonthPattern] Expected calID > 1");
- result = CalendarTable.Default.SYEARMONTH(calID)[0];
-
- BCLDebug.Assert(result.Length != 0, "Calendar.nlp should have SYEARMONTH value");
- }
- else {
-
- result = this.m_cultureTableRecord.SYEARMONTHS[0];
- }
- return (result);
-
- }
-
-
- public string YearMonthPattern {
- get {
- BCLDebug.Assert(yearMonthPattern != null, "DateTimeFormatInfo.YearMonthPattern: yearMonthPattern != null");
- return (yearMonthPattern);
- }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_String"));
- }
- yearMonthPattern = value;
- SetDefaultPatternAsFirstItem(allYearMonthPatterns, yearMonthPattern);
- }
- }
-
-
-
-
-
- private void CheckNullValue(string[] values, int length)
- {
- BCLDebug.Assert(values != null, "value != null");
- for (int i = 0; i < length; i++) {
- if (values[i] == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_ArrayValue"));
- }
- }
- }
-
-
- public string[] AbbreviatedDayNames {
- get { return ((string[])GetAbbreviatedDayOfWeekNames().Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 7) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 7), "value");
- }
- CheckNullValue(value, value.Length);
- ClearTokenHashTable(true);
- abbreviatedDayNames = value;
- }
- }
-
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public string[] ShortestDayNames {
- get { return ((string[])internalGetSuperShortDayNames().Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 7) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 7), "value");
- }
- CheckNullValue(value, value.Length);
- this.m_superShortDayNames = value;
- }
- }
-
-
- public string[] DayNames {
- get { return ((string[])GetDayOfWeekNames().Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 7) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 7), "value");
- }
- CheckNullValue(value, value.Length);
- ClearTokenHashTable(true);
- dayNames = value;
- }
- }
-
-
- public string[] AbbreviatedMonthNames {
- get { return ((string[])GetAbbreviatedMonthNames().Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 13) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 13), "value");
- }
- CheckNullValue(value, value.Length - 1);
- ClearTokenHashTable(true);
- abbreviatedMonthNames = value;
- }
- }
-
-
- public string[] MonthNames {
- get { return ((string[])GetMonthNames().Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 13) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 13), "value");
- }
- CheckNullValue(value, value.Length - 1);
- monthNames = value;
- ClearTokenHashTable(true);
- }
- }
-
-
-
- static char[] MonthSpaces = {' ', ' '};
-
- internal bool HasSpacesInMonthNames {
- get { return (FormatFlags & DateTimeFormatFlags.UseSpacesInMonthNames) != 0; }
- }
-
- internal bool HasSpacesInDayNames {
- get { return (FormatFlags & DateTimeFormatFlags.UseSpacesInDayNames) != 0; }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- internal string internalGetMonthName(int month, MonthNameStyles style, bool abbreviated)
- {
-
-
-
-
- string[] monthNamesArray = null;
- switch (style) {
- case MonthNameStyles.Genitive:
- monthNamesArray = internalGetGenitiveMonthNames(abbreviated);
- break;
- case MonthNameStyles.LeapYear:
- monthNamesArray = internalGetLeapYearMonthNames();
- break;
- default:
- monthNamesArray = (abbreviated ? GetAbbreviatedMonthNames() : GetMonthNames());
- break;
- }
-
-
- if ((month < 1) || (month > monthNamesArray.Length)) {
- throw new ArgumentOutOfRangeException("month", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 1, monthNamesArray.Length));
- }
- return (monthNamesArray[month - 1]);
- }
-
-
-
-
-
-
-
-
-
- private string[] internalGetGenitiveMonthNames(bool abbreviated)
- {
- if (abbreviated) {
- if (this.m_genitiveAbbreviatedMonthNames == null) {
- if (m_isDefaultCalendar) {
-
- string[] temp = this.m_cultureTableRecord.SABBREVMONTHGENITIVENAMES;
- if (temp.Length > 0) {
-
- this.m_genitiveAbbreviatedMonthNames = temp;
- }
- else {
-
- this.m_genitiveAbbreviatedMonthNames = GetAbbreviatedMonthNames();
- }
- }
- else {
- this.m_genitiveAbbreviatedMonthNames = GetAbbreviatedMonthNames();
- }
- BCLDebug.Assert(this.m_genitiveAbbreviatedMonthNames.Length == 13, "[DateTimeFormatInfo.GetGenitiveMonthNames] Expected 13 abbreviated genitive month names in a year");
- }
- return (this.m_genitiveAbbreviatedMonthNames);
- }
-
- if (genitiveMonthNames == null) {
- if (m_isDefaultCalendar) {
-
- string[] temp = this.m_cultureTableRecord.SMONTHGENITIVENAMES;
- if (temp.Length > 0) {
-
- genitiveMonthNames = temp;
- }
- else {
-
- genitiveMonthNames = GetMonthNames();
- }
- }
- else {
- genitiveMonthNames = GetMonthNames();
- }
- BCLDebug.Assert(genitiveMonthNames.Length == 13, "[DateTimeFormatInfo.GetGenitiveMonthNames] Expected 13 genitive month names in a year");
- }
- return (genitiveMonthNames);
- }
-
-
-
-
-
-
-
-
- internal string[] internalGetLeapYearMonthNames()
- {
- if (leapYearMonthNames == null) {
- if (m_isDefaultCalendar) {
-
-
-
-
- leapYearMonthNames = GetMonthNames();
- }
- else {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.internalGetLeapYearMonthNames] Expected Calendar.ID > 0");
- string[] temp = CalendarTable.Default.SLEAPYEARMONTHNAMES(Calendar.ID);
- if (temp.Length > 0) {
- leapYearMonthNames = temp;
- }
- else {
- leapYearMonthNames = GetMonthNames();
- }
- }
- }
- return (leapYearMonthNames);
- }
-
-
- public string GetAbbreviatedDayName(DayOfWeek dayofweek)
- {
-
- if ((int)dayofweek < 0 || (int)dayofweek > 6) {
- throw new ArgumentOutOfRangeException("dayofweek", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), DayOfWeek.Sunday, DayOfWeek.Saturday));
- }
-
-
-
-
- return (GetAbbreviatedDayOfWeekNames()[(int)dayofweek]);
- }
-
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public string GetShortestDayName(DayOfWeek dayOfWeek)
- {
-
- if ((int)dayOfWeek < 0 || (int)dayOfWeek > 6) {
- throw new ArgumentOutOfRangeException("dayOfWeek", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), DayOfWeek.Sunday, DayOfWeek.Saturday));
- }
-
-
-
-
- return (internalGetSuperShortDayNames()[(int)dayOfWeek]);
- }
-
-
- internal string[] GetCombinedPatterns(string[] patterns1, string[] patterns2, string connectString)
- {
- string[] result = new string[patterns1.Length * patterns2.Length];
- for (int i = 0; i < patterns1.Length; i++) {
- for (int j = 0; j < patterns2.Length; j++) {
- result[i * patterns2.Length + j] = patterns1[i] + connectString + patterns2[j];
- }
- }
- return (result);
- }
-
-
- public string[] GetAllDateTimePatterns()
- {
- ArrayList results = new ArrayList(DEFAULT_ALL_DATETIMES_SIZE);
-
- for (int i = 0; i < DateTimeFormat.allStandardFormats.Length; i++) {
- string[] strings = GetAllDateTimePatterns(DateTimeFormat.allStandardFormats[i]);
- for (int j = 0; j < strings.Length; j++) {
- results.Add(strings[j]);
- }
- }
- string[] value = new string[results.Count];
- results.CopyTo(0, value, 0, results.Count);
- return (value);
- }
-
-
- public string[] GetAllDateTimePatterns(char format)
- {
- string[] result = null;
-
- switch (format) {
- case 'd':
- result = ClonedAllShortDatePatterns;
- break;
- case 'D':
- result = ClonedAllLongDatePatterns;
- break;
- case 'f':
- result = GetCombinedPatterns(ClonedAllLongDatePatterns, ClonedAllShortTimePatterns, " ");
- break;
- case 'F':
- result = GetCombinedPatterns(ClonedAllLongDatePatterns, ClonedAllLongTimePatterns, " ");
- break;
- case 'g':
- result = GetCombinedPatterns(ClonedAllShortDatePatterns, ClonedAllShortTimePatterns, " ");
- break;
- case 'G':
- result = GetCombinedPatterns(ClonedAllShortDatePatterns, ClonedAllLongTimePatterns, " ");
- break;
- case 'm':
- case 'M':
- result = new string[] {MonthDayPattern};
- break;
- case 'o':
- case 'O':
- result = new string[] {DateTimeFormat.RoundtripFormat};
- break;
- case 'r':
- case 'R':
- result = new string[] {rfc1123Pattern};
- break;
- case 's':
- result = new string[] {sortableDateTimePattern};
- break;
- case 't':
- result = ClonedAllShortTimePatterns;
- break;
- case 'T':
- result = ClonedAllLongTimePatterns;
- break;
- case 'u':
- result = new string[] {UniversalSortableDateTimePattern};
- break;
- case 'U':
- result = GetCombinedPatterns(ClonedAllLongDatePatterns, ClonedAllLongTimePatterns, " ");
- break;
- case 'y':
- case 'Y':
- result = ClonedAllYearMonthPatterns;
- break;
- default:
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFormatSpecifier"), "format");
- break;
- }
- return (result);
- }
-
-
- public string GetDayName(DayOfWeek dayofweek)
- {
- if ((int)dayofweek < 0 || (int)dayofweek > 6) {
- throw new ArgumentOutOfRangeException("dayofweek", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), DayOfWeek.Sunday, DayOfWeek.Saturday));
- }
-
- return (GetDayOfWeekNames()[(int)dayofweek]);
- }
-
-
-
- public string GetAbbreviatedMonthName(int month)
- {
- if (month < 1 || month > 13) {
- throw new ArgumentOutOfRangeException("month", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 1, 13));
- }
- return (GetAbbreviatedMonthNames()[month - 1]);
- }
-
-
- public string GetMonthName(int month)
- {
- if (month < 1 || month > 13) {
- throw new ArgumentOutOfRangeException("month", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), 1, 13));
- }
- return (GetMonthNames()[month - 1]);
- }
-
-
-
- internal string[] ClonedAllYearMonthPatterns {
- get {
- if (allYearMonthPatterns == null) {
- string[] temp = null;
-
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AllYearMonthPatternsNeedClone] Expected Calendar.ID > 0");
-
- temp = CalendarTable.Default.SYEARMONTH(Calendar.ID);
-
-
-
-
- if (temp == null) {
- temp = this.m_cultureTableRecord.SYEARMONTHS;
- }
- }
- else {
- temp = this.m_cultureTableRecord.SYEARMONTHS;
- }
-
- System.Threading.Thread.MemoryBarrier();
- SetDefaultPatternAsFirstItem(temp, YearMonthPattern);
- allYearMonthPatterns = temp;
- }
-
- if (allYearMonthPatterns[0].Equals(YearMonthPattern)) {
- return (string[])allYearMonthPatterns.Clone();
- }
-
- return AddDefaultFormat(allYearMonthPatterns, YearMonthPattern);
- }
- }
-
-
-
- internal string[] ClonedAllShortDatePatterns {
- get {
- if (allShortDatePatterns == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AllShortDatePatternsNeedClone] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SSHORTDATE(Calendar.ID);
-
-
-
- if (temp == null) {
- temp = this.m_cultureTableRecord.SSHORTDATES;
- }
- }
- else {
- temp = this.m_cultureTableRecord.SSHORTDATES;
- }
- System.Threading.Thread.MemoryBarrier();
- SetDefaultPatternAsFirstItem(temp, ShortDatePattern);
- allShortDatePatterns = temp;
- }
-
- if (allShortDatePatterns[0].Equals(ShortDatePattern)) {
- return (string[])allShortDatePatterns.Clone();
- }
-
- return (AddDefaultFormat(allShortDatePatterns, ShortDatePattern));
- }
- }
-
-
- internal string[] ClonedAllLongDatePatterns {
- get {
- if (allLongDatePatterns == null) {
- string[] temp = null;
- if (!m_isDefaultCalendar) {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.AllLongDatePatternsNeedClone] Expected Calendar.ID > 0");
- temp = CalendarTable.Default.SLONGDATE(Calendar.ID);
-
-
-
- if (temp == null) {
- temp = this.m_cultureTableRecord.SLONGDATES;
- }
- }
- else {
- temp = this.m_cultureTableRecord.SLONGDATES;
- }
- System.Threading.Thread.MemoryBarrier();
- SetDefaultPatternAsFirstItem(temp, LongDatePattern);
- allLongDatePatterns = temp;
- }
-
- if (allLongDatePatterns[0].Equals(LongDatePattern)) {
- return (string[])allLongDatePatterns.Clone();
- }
-
- return (AddDefaultFormat(allLongDatePatterns, LongDatePattern));
- }
- }
-
- internal void SetDefaultPatternAsFirstItem(string[] patterns, string defaultPattern)
- {
- if (patterns == null) {
- return;
- }
-
- for (int i = 0; i < patterns.Length; i++) {
- if (patterns[i].Equals(defaultPattern)) {
- if (i != 0) {
-
- string temp = patterns[i];
-
- for (int j = i; j > 0; j--) {
- patterns[j] = patterns[j - 1];
- }
-
- patterns[0] = temp;
- }
-
- return;
- }
- }
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
- internal string[] AddDefaultFormat(string[] datePatterns, string defaultDateFormat)
- {
- string[] updatedPatterns = new string[datePatterns.Length + 1];
- updatedPatterns[0] = defaultDateFormat;
- Array.Copy(datePatterns, 0, updatedPatterns, 1, datePatterns.Length);
-
- m_scanDateWords = true;
- return updatedPatterns;
- }
-
-
- internal string[] ClonedAllShortTimePatterns {
- get {
- if (allShortTimePatterns == null) {
- allShortTimePatterns = this.m_cultureTableRecord.SSHORTTIMES;
- SetDefaultPatternAsFirstItem(allShortTimePatterns, ShortTimePattern);
- }
-
- if (allShortTimePatterns[0].Equals(ShortTimePattern)) {
- return (string[])allShortTimePatterns.Clone();
- }
-
- return (AddDefaultFormat(allShortTimePatterns, ShortTimePattern));
- }
- }
-
- internal string[] ClonedAllLongTimePatterns {
- get {
- if (allLongTimePatterns == null) {
- allLongTimePatterns = this.m_cultureTableRecord.STIMEFORMATS;
- SetDefaultPatternAsFirstItem(allLongTimePatterns, LongTimePattern);
- }
- if (allLongTimePatterns[0].Equals(LongTimePattern)) {
- return (string[])allLongTimePatterns.Clone();
- }
-
- return (AddDefaultFormat(allLongTimePatterns, LongTimePattern));
- }
- }
-
-
-
-
-
-
- internal string[] DateWords {
- get {
- if (m_dateWords == null) {
- m_dateWords = this.m_cultureTableRecord.SDATEWORDS;
- }
-
- return (m_dateWords);
- }
- }
-
-
- public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi)
- {
- if (dtfi == null) {
- throw new ArgumentNullException("dtfi", Environment.GetResourceString("ArgumentNull_Obj"));
- }
- if (dtfi.IsReadOnly) {
- return (dtfi);
- }
- DateTimeFormatInfo info = (DateTimeFormatInfo)(dtfi.MemberwiseClone());
- info.Calendar = Calendar.ReadOnly(info.Calendar);
- info.m_isReadOnly = true;
- return (info);
- }
-
-
- public bool IsReadOnly {
- get { return (m_isReadOnly); }
- }
-
- private static int CalendarIdToCultureId(int calendarId)
- {
- switch (calendarId) {
- case Calendar.CAL_GREGORIAN_US:
- return 1065;
- case Calendar.CAL_JAPAN:
-
- return 1041;
- case Calendar.CAL_TAIWAN:
-
- return 1028;
- case Calendar.CAL_KOREA:
-
- return 1042;
- case Calendar.CAL_HIJRI:
- case Calendar.CAL_GREGORIAN_ARABIC:
- case Calendar.CAL_UMALQURA:
-
- return 1025;
- case Calendar.CAL_THAI:
-
- return 1054;
- case Calendar.CAL_HEBREW:
-
- return 1037;
- case Calendar.CAL_GREGORIAN_ME_FRENCH:
-
- return 5121;
- case Calendar.CAL_GREGORIAN_XLIT_ENGLISH:
- case Calendar.CAL_GREGORIAN_XLIT_FRENCH:
-
- return 2049;
- default:
-
- BCLDebug.Assert(false, "[DateTimeFormatInfo.CalendarIdToCultureId] we shouldn't come here.");
- break;
- }
-
- return 0;
- }
-
-
-
-
-
-
-
- private string GetCalendarNativeNameFallback(int calendarId)
- {
- BCLDebug.Assert(calendarId != Calendar.CAL_GREGORIAN, "[DateTimeFormatInfo.GetCalendarNativeNameFallback] Unexpected Gregorian localized calendar.");
-
- if (m_calendarNativeNames == null) {
- lock (InternalSyncObject) {
- if (m_calendarNativeNames == null)
- m_calendarNativeNames = new Hashtable();
- }
- }
-
- BCLDebug.Assert(m_calendarNativeNames != null, "[DateTimeFormatInfo.GetCalendarNativeNameFallback] m_calendarNativeNames should be valid");
-
- string temp = (string)m_calendarNativeNames[calendarId];
- if (temp != null)
- return temp;
-
- string name = String.Empty;
-
- int cultureId = CalendarIdToCultureId(calendarId);
-
- if (cultureId != 0) {
- string[] values = new CultureTableRecord(cultureId, false).SNATIVECALNAMES;
-
- BCLDebug.Assert(calendar.ID >= 1, "[DateTimeFormatInfo.GetCalendarNativeNameFallback] calendar.ID >= 1");
-
- int id = calendar.ID - 1;
-
-
- if (id < values.Length) {
-
- if (values[id].Length > 0 && values[id][0] != '')
- name = values[id];
- }
- }
-
- lock (InternalSyncObject) {
- if (m_calendarNativeNames[calendarId] == null)
- m_calendarNativeNames[calendarId] = name;
- }
-
- return name;
- }
-
-
-
-
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public string NativeCalendarName {
- get {
-
- if (Calendar.ID == Calendar.CAL_TAIWAN) {
-
-
-
-
-
-
- string result = GetCalendarInfo(1028, Calendar.CAL_TAIWAN, CAL_SCALNAME);
- if (result == null) {
-
-
-
- result = CalendarTable.nativeGetEraName(1028, Calendar.CAL_TAIWAN);
- if (result == null) {
-
- result = String.Empty;
- }
- }
- return (result);
- }
- else {
- string[] values = this.m_cultureTableRecord.SNATIVECALNAMES;
- BCLDebug.Assert(calendar.ID >= 1, "calendar.ID >= 1");
- int id = calendar.ID - 1;
-
- if (id < values.Length) {
- if (values[id].Length > 0) {
-
- if (values[id][0] != '')
- return (values[id]);
- }
- else {
-
-
-
- BCLDebug.Assert(this.m_cultureTableRecord.IsCustomCulture, "[DateTimeFormatInfo.NativeCalendarName] Expected custom culture");
- return GetCalendarNativeNameFallback(calendar.ID);
- }
- }
- }
-
- return (String.Empty);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public void SetAllDateTimePatterns(string[] patterns, char format)
- {
- VerifyWritable();
- if (patterns == null) {
- throw new ArgumentNullException("patterns", Environment.GetResourceString("ArgumentNull_Array"));
- }
-
- if (patterns.Length == 0) {
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError"), "patterns");
- }
-
- for (int i = 0; i < patterns.Length; i++) {
- if (patterns[i] == null) {
- throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_ArrayValue"));
- }
- }
-
- switch (format) {
- case 'd':
- ShortDatePattern = patterns[0];
- this.allShortDatePatterns = patterns;
- break;
- case 'D':
-
- LongDatePattern = patterns[0];
- this.allLongDatePatterns = patterns;
- break;
- case 't':
-
- ShortTimePattern = patterns[0];
- this.allShortTimePatterns = patterns;
- break;
- case 'T':
-
- LongTimePattern = patterns[0];
- this.allLongTimePatterns = patterns;
- break;
- case 'y':
- case 'Y':
-
- yearMonthPattern = patterns[0];
- this.allYearMonthPatterns = patterns;
- break;
- default:
-
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFormatSpecifier"), "format");
- break;
- }
- return;
- }
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public string[] AbbreviatedMonthGenitiveNames {
- get { return ((string[])internalGetGenitiveMonthNames(true).Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 13) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 13), "value");
- }
- CheckNullValue(value, value.Length - 1);
- ClearTokenHashTable(true);
- this.m_genitiveAbbreviatedMonthNames = value;
- }
- }
-
- [System.Runtime.InteropServices.ComVisible(false)]
- public string[] MonthGenitiveNames {
- get { return ((string[])internalGetGenitiveMonthNames(false).Clone()); }
-
- set {
- VerifyWritable();
- if (value == null) {
- throw new ArgumentNullException("value", Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (value.Length != 13) {
- throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidArrayLength"), 13), "value");
- }
- CheckNullValue(value, value.Length - 1);
- genitiveMonthNames = value;
- ClearTokenHashTable(true);
- }
- }
-
-
-
-
-
-
- internal CompareInfo CompareInfo {
- get {
- if (m_compareInfo == null) {
-
-
- if (CultureTableRecord.IsCustomCultureId(CultureId))
- m_compareInfo = CompareInfo.GetCompareInfo((int)m_cultureTableRecord.ICOMPAREINFO);
- else
- m_compareInfo = CompareInfo.GetCompareInfo(CultureId);
- }
-
- return m_compareInfo;
- }
- }
-
-
- private void VerifyWritable()
- {
- if (m_isReadOnly) {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly"));
- }
- }
-
-
- private const DateTimeStyles InvalidDateTimeStyles = ~(DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite | DateTimeStyles.AllowInnerWhite | DateTimeStyles.NoCurrentDateDefault | DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal | DateTimeStyles.AssumeUniversal | DateTimeStyles.RoundtripKind);
-
- static internal void ValidateStyles(DateTimeStyles style, string parameterName)
- {
- if ((style & InvalidDateTimeStyles) != 0) {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeStyles"), parameterName);
- }
- if (((style & (DateTimeStyles.AssumeLocal)) != 0) && ((style & (DateTimeStyles.AssumeUniversal)) != 0)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_ConflictingDateTimeStyles"), parameterName);
- }
- if (((style & DateTimeStyles.RoundtripKind) != 0) && ((style & (DateTimeStyles.AssumeLocal | DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)) != 0)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_ConflictingDateTimeRoundtripStyles"), parameterName);
- }
- }
-
-
-
-
-
- internal DateTimeFormatFlags FormatFlags {
- get {
- if (formatFlags == DateTimeFormatFlags.NotInitialized) {
- if (m_scanDateWords || m_cultureTableRecord.IsSynthetic) {
- formatFlags = DateTimeFormatFlags.None;
- formatFlags |= (DateTimeFormatFlags)DateTimeFormatInfoScanner.GetFormatFlagGenitiveMonth(MonthNames, internalGetGenitiveMonthNames(false), AbbreviatedMonthNames, internalGetGenitiveMonthNames(true));
- formatFlags |= (DateTimeFormatFlags)DateTimeFormatInfoScanner.GetFormatFlagUseSpaceInMonthNames(MonthNames, internalGetGenitiveMonthNames(false), AbbreviatedMonthNames, internalGetGenitiveMonthNames(true));
- formatFlags |= (DateTimeFormatFlags)DateTimeFormatInfoScanner.GetFormatFlagUseSpaceInDayNames(DayNames, AbbreviatedDayNames);
- formatFlags |= (DateTimeFormatFlags)DateTimeFormatInfoScanner.GetFormatFlagUseHebrewCalendar((int)Calendar.ID);
- }
- else {
-
- if (m_isDefaultCalendar) {
- formatFlags = this.m_cultureTableRecord.IFORMATFLAGS;
- }
- else {
- BCLDebug.Assert(Calendar.ID > 0, "[DateTimeFormatInfo.FormatFlags] Expected Calendar.ID > 0");
- formatFlags = (DateTimeFormatFlags)CalendarTable.Default.IFORMATFLAGS(Calendar.ID);
- }
- }
- }
- return (formatFlags);
- }
- }
-
- internal bool HasForceTwoDigitYears {
- get {
- switch (calendar.ID) {
- case (Calendar.CAL_JAPAN):
- case (Calendar.CAL_TAIWAN):
-
-
-
-
-
-
-
-
- return true;
- }
- return false;
- }
- }
-
-
- internal bool HasYearMonthAdjustment {
- get { return ((FormatFlags & DateTimeFormatFlags.UseHebrewRule) != 0); }
- }
-
-
-
-
-
-
- internal bool YearMonthAdjustment(ref int year, ref int month, bool parsedMonthName)
- {
- if ((FormatFlags & DateTimeFormatFlags.UseHebrewRule) != 0) {
-
-
-
-
-
- if (year < 1000) {
- year += 5000;
- }
-
-
- if (year < Calendar.GetYear(Calendar.MinSupportedDateTime) || year > Calendar.GetYear(Calendar.MaxSupportedDateTime)) {
- return false;
- }
-
-
-
-
- if (parsedMonthName) {
- if (!Calendar.IsLeapYear(year)) {
- if (month >= 8) {
- month--;
- }
- else if (month == 7) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
-
-
-
- [NonSerialized()]
- TokenHashValue[] m_dtfiTokenHash;
-
- [NonSerialized()]
- bool m_scanDateWords = false;
-
-
- private const int TOKEN_HASH_SIZE = 199;
- private const int SECOND_PRIME = 197;
- private const string alternativeDateSeparator = "-";
- private const string invariantDateSeparator = "/";
- private const string invariantTimeSeparator = ":";
-
-
-
-
- internal const string CJKYearSuff = "年";
- internal const string CJKMonthSuff = "月";
- internal const string CJKDaySuff = "日";
-
- internal const string KoreanYearSuff = "년";
- internal const string KoreanMonthSuff = "월";
- internal const string KoreanDaySuff = "일";
-
- internal const string KoreanHourSuff = "시";
- internal const string KoreanMinuteSuff = "분";
- internal const string KoreanSecondSuff = "초";
-
- internal const string CJKHourSuff = "時";
- internal const string ChineseHourSuff = "时";
-
- internal const string CJKMinuteSuff = "分";
- internal const string CJKSecondSuff = "秒";
-
- internal const string LocalTimeMark = "T";
-
- internal const string KoreanLangName = "ko";
- internal const string JapaneseLangName = "ja";
- internal const string EnglishLangName = "en";
-
- private static DateTimeFormatInfo m_jajpDTFI = null;
- private static DateTimeFormatInfo m_zhtwDTFI = null;
-
-
-
-
-
-
-
- static internal DateTimeFormatInfo GetJapaneseCalendarDTFI()
- {
- DateTimeFormatInfo temp = m_jajpDTFI;
- if (temp == null) {
- temp = new CultureInfo("ja-JP", false).DateTimeFormat;
- temp.Calendar = JapaneseCalendar.GetDefaultInstance();
- m_jajpDTFI = temp;
- }
- return (temp);
- }
-
-
-
-
-
-
-
-
- static internal DateTimeFormatInfo GetTaiwanCalendarDTFI()
- {
- DateTimeFormatInfo temp = m_zhtwDTFI;
- if (temp == null) {
- temp = new CultureInfo("zh-TW", false).DateTimeFormat;
- temp.Calendar = TaiwanCalendar.GetDefaultInstance();
- m_zhtwDTFI = temp;
- }
- return (temp);
- }
-
-
-
- private void ClearTokenHashTable(bool scanDateWords)
- {
- m_dtfiTokenHash = null;
- m_dateWords = null;
-
-
- m_scanDateWords = scanDateWords;
- formatFlags = DateTimeFormatFlags.NotInitialized;
- }
-
- internal TokenHashValue[] CreateTokenHashTable()
- {
- TokenHashValue[] temp = m_dtfiTokenHash;
- if (temp == null) {
- temp = new TokenHashValue[TOKEN_HASH_SIZE];
-
- InsertHash(temp, ",", TokenType.IgnorableSymbol, 0);
- InsertHash(temp, ".", TokenType.IgnorableSymbol, 0);
-
- InsertHash(temp, this.TimeSeparator, TokenType.SEP_Time, 0);
- InsertHash(temp, this.AMDesignator, TokenType.SEP_Am | TokenType.Am, 0);
- InsertHash(temp, this.PMDesignator, TokenType.SEP_Pm | TokenType.Pm, 1);
-
- if (CultureName.Equals("sq-AL")) {
-
- InsertHash(temp, "." + this.AMDesignator, TokenType.SEP_Am | TokenType.Am, 0);
- InsertHash(temp, "." + this.PMDesignator, TokenType.SEP_Pm | TokenType.Pm, 1);
- }
-
-
- InsertHash(temp, CJKYearSuff, TokenType.SEP_YearSuff, 0);
- InsertHash(temp, KoreanYearSuff, TokenType.SEP_YearSuff, 0);
- InsertHash(temp, CJKMonthSuff, TokenType.SEP_MonthSuff, 0);
- InsertHash(temp, KoreanMonthSuff, TokenType.SEP_MonthSuff, 0);
- InsertHash(temp, CJKDaySuff, TokenType.SEP_DaySuff, 0);
- InsertHash(temp, KoreanDaySuff, TokenType.SEP_DaySuff, 0);
-
- InsertHash(temp, CJKHourSuff, TokenType.SEP_HourSuff, 0);
- InsertHash(temp, ChineseHourSuff, TokenType.SEP_HourSuff, 0);
- InsertHash(temp, CJKMinuteSuff, TokenType.SEP_MinuteSuff, 0);
- InsertHash(temp, CJKSecondSuff, TokenType.SEP_SecondSuff, 0);
-
- if (LanguageName.Equals(KoreanLangName)) {
-
- InsertHash(temp, KoreanHourSuff, TokenType.SEP_HourSuff, 0);
- InsertHash(temp, KoreanMinuteSuff, TokenType.SEP_MinuteSuff, 0);
- InsertHash(temp, KoreanSecondSuff, TokenType.SEP_SecondSuff, 0);
- }
-
- string[] dateWords = null;
- DateTimeFormatInfoScanner scanner = null;
-
-
-
-
-
- if (!m_scanDateWords) {
- dateWords = ClonedAllLongDatePatterns;
- }
- if (m_scanDateWords || m_cultureTableRecord.IsSynthetic) {
- scanner = new DateTimeFormatInfoScanner();
-
- m_dateWords = dateWords = scanner.GetDateWordsOfDTFI(this);
-
- DateTimeFormatFlags flag = FormatFlags;
- m_scanDateWords = false;
- }
- else {
-
- dateWords = this.DateWords;
- ;
- }
-
-
-
-
- bool useDateSepAsIgnorableSymbol = false;
-
- string monthPostfix = null;
- if (dateWords != null) {
-
-
- for (int i = 0; i < dateWords.Length; i++) {
- switch (dateWords[i][0]) {
- case DateTimeFormatInfoScanner.MonthPostfixChar:
-
-
- monthPostfix = dateWords[i].Substring(1);
-
- AddMonthNames(temp, monthPostfix);
- break;
- case DateTimeFormatInfoScanner.IgnorableSymbolChar:
- string symbol = dateWords[i].Substring(1);
- InsertHash(temp, symbol, TokenType.IgnorableSymbol, 0);
- if (this.DateSeparator.Trim(null).Equals(symbol)) {
-
- useDateSepAsIgnorableSymbol = true;
- }
- break;
- default:
- InsertHash(temp, dateWords[i], TokenType.DateWordToken, 0);
- if (CultureName.Equals("eu-ES")) {
-
- InsertHash(temp, "." + dateWords[i], TokenType.DateWordToken, 0);
- }
- break;
- }
- }
- }
-
- if (!useDateSepAsIgnorableSymbol) {
-
- InsertHash(temp, this.DateSeparator, TokenType.SEP_Date, 0);
- }
-
- AddMonthNames(temp, null);
-
-
- for (int i = 1; i <= 13; i++) {
- InsertHash(temp, GetAbbreviatedMonthName(i), TokenType.MonthToken, i);
- }
-
-
- if (CultureName.Equals("gl-ES")) {
-
-
-
-
-
-
- for (int i = 1; i <= 13; i++) {
- string str;
-
-
-
-
- str = GetMonthName(i);
- if (str.Length > 0) {
-
- InsertHash(temp, str + "de", TokenType.MonthToken, i);
- }
- }
- }
-
- if ((FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != 0) {
- for (int i = 1; i <= 13; i++) {
- string str;
- str = internalGetMonthName(i, MonthNameStyles.Genitive, false);
- InsertHash(temp, str, TokenType.MonthToken, i);
- }
- }
-
- if ((FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != 0) {
- for (int i = 1; i <= 13; i++) {
- string str;
- str = internalGetMonthName(i, MonthNameStyles.LeapYear, false);
- InsertHash(temp, str, TokenType.MonthToken, i);
- }
- }
-
- for (int i = 0; i < 7; i++) {
-
-
- string str = GetDayName((DayOfWeek)i);
- InsertHash(temp, str, TokenType.DayOfWeekToken, i);
-
- str = GetAbbreviatedDayName((DayOfWeek)i);
- InsertHash(temp, str, TokenType.DayOfWeekToken, i);
-
- }
-
- int[] eras = calendar.Eras;
- for (int i = 1; i <= eras.Length; i++) {
- InsertHash(temp, GetEraName(i), TokenType.EraToken, i);
- InsertHash(temp, GetAbbreviatedEraName(i), TokenType.EraToken, i);
- }
-
- if (LanguageName.Equals(JapaneseLangName)) {
-
- for (int i = 0; i < 7; i++) {
- string specialDayOfWeek = "(" + GetAbbreviatedDayName((DayOfWeek)i) + ")";
- InsertHash(temp, specialDayOfWeek, TokenType.DayOfWeekToken, i);
- }
- if (this.Calendar.GetType() != typeof(JapaneseCalendar)) {
-
-
- DateTimeFormatInfo jaDtfi = GetJapaneseCalendarDTFI();
- for (int i = 1; i <= jaDtfi.Calendar.Eras.Length; i++) {
- InsertHash(temp, jaDtfi.GetEraName(i), TokenType.JapaneseEraToken, i);
- InsertHash(temp, jaDtfi.GetAbbreviatedEraName(i), TokenType.JapaneseEraToken, i);
-
- InsertHash(temp, jaDtfi.AbbreviatedEnglishEraNames[i - 1], TokenType.JapaneseEraToken, i);
- }
- }
- }
- else if (CultureName.Equals("zh-TW")) {
- DateTimeFormatInfo twDtfi = GetTaiwanCalendarDTFI();
- for (int i = 1; i <= twDtfi.Calendar.Eras.Length; i++) {
- if (twDtfi.GetEraName(i).Length > 0) {
- InsertHash(temp, twDtfi.GetEraName(i), TokenType.TEraToken, i);
- }
- }
- }
-
- InsertHash(temp, InvariantInfo.AMDesignator, TokenType.SEP_Am | TokenType.Am, 0);
- InsertHash(temp, InvariantInfo.PMDesignator, TokenType.SEP_Pm | TokenType.Pm, 1);
-
-
- for (int i = 1; i <= 12; i++) {
- string str;
-
-
-
- str = InvariantInfo.GetMonthName(i);
- InsertHash(temp, str, TokenType.MonthToken, i);
- str = InvariantInfo.GetAbbreviatedMonthName(i);
- InsertHash(temp, str, TokenType.MonthToken, i);
- }
-
- for (int i = 0; i < 7; i++) {
-
- string str = InvariantInfo.GetDayName((DayOfWeek)i);
- InsertHash(temp, str, TokenType.DayOfWeekToken, i);
-
- str = InvariantInfo.GetAbbreviatedDayName((DayOfWeek)i);
- InsertHash(temp, str, TokenType.DayOfWeekToken, i);
-
- }
-
- for (int i = 0; i < AbbreviatedEnglishEraNames.Length; i++) {
-
- InsertHash(temp, AbbreviatedEnglishEraNames[i], TokenType.EraToken, i + 1);
- }
-
- InsertHash(temp, LocalTimeMark, TokenType.SEP_LocalTimeMark, 0);
- InsertHash(temp, DateTimeParse.GMTName, TokenType.TimeZoneToken, 0);
- InsertHash(temp, DateTimeParse.ZuluName, TokenType.TimeZoneToken, 0);
-
- InsertHash(temp, invariantDateSeparator, TokenType.SEP_Date, 0);
- InsertHash(temp, invariantTimeSeparator, TokenType.SEP_Time, 0);
-
- if (CultureName.Equals("ky-KG")) {
-
- InsertHash(temp, alternativeDateSeparator, TokenType.IgnorableSymbol, 0);
- }
- else {
- InsertHash(temp, alternativeDateSeparator, TokenType.SEP_Date, 0);
- }
-
- m_dtfiTokenHash = temp;
- }
- return (temp);
- }
-
- private void AddMonthNames(TokenHashValue[] temp, string monthPostfix)
- {
- for (int i = 1; i <= 13; i++) {
- string str;
-
-
-
-
- str = GetMonthName(i);
- if (str.Length > 0) {
- if (monthPostfix != null) {
-
- InsertHash(temp, str + monthPostfix, TokenType.MonthToken, i);
- }
- else {
- InsertHash(temp, str, TokenType.MonthToken, i);
- }
- }
- str = GetAbbreviatedMonthName(i);
- InsertHash(temp, str, TokenType.MonthToken, i);
- }
-
- }
-
- ////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
-
-
-
- ////////////////////////////////////////////////////////////////////////
-
- private static bool TryParseHebrewNumber(ref __DTString str, out bool badFormat, out int number)
- {
-
- number = -1;
- badFormat = false;
-
- int i = str.Index;
- if (!HebrewNumber.IsDigit(str.Value[i])) {
-
-
- return (false);
- }
-
- HebrewNumberParsingContext context = new HebrewNumberParsingContext(0);
- HebrewNumberParsingState state;
-
- do {
- state = HebrewNumber.ParseByChar(str.Value[i++], ref context);
- switch (state) {
- case HebrewNumberParsingState.InvalidHebrewNumber:
- case HebrewNumberParsingState.NotHebrewDigit:
-
-
-
- return (false);
- }
- }
- while (i < str.Value.Length && (state != HebrewNumberParsingState.FoundEndOfHebrewNumber));
-
-
- BCLDebug.Assert(state == HebrewNumberParsingState.ContinueParsing || state == HebrewNumberParsingState.FoundEndOfHebrewNumber, "Invalid returned state from HebrewNumber.ParseByChar()");
-
- if (state != HebrewNumberParsingState.FoundEndOfHebrewNumber) {
-
- return (false);
- }
-
-
- str.Advance(i - str.Index);
-
-
- number = context.result;
-
- return (true);
- }
-
- private static bool IsHebrewChar(char ch)
- {
- return (ch >= '' && ch <= '');
- }
-
- internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tokenValue, ref __DTString str)
- {
- tokenType = TokenType.UnknownToken;
- tokenValue = 0;
-
- TokenHashValue value;
- BCLDebug.Assert(str.Index < str.Value.Length, "DateTimeFormatInfo.Tokenize(): start < value.Length");
-
- char ch = str.m_current;
- bool isLetter = Char.IsLetter(ch);
- if (isLetter) {
- ch = Char.ToLower(ch, CultureInfo.CurrentCulture);
- if (IsHebrewChar(ch) && TokenMask == TokenType.RegularTokenMask) {
- bool badFormat;
- if (TryParseHebrewNumber(ref str, out badFormat, out tokenValue)) {
- if (badFormat) {
- tokenType = TokenType.UnknownToken;
- return (false);
- }
-
-
- tokenType = TokenType.HebrewNumber;
- return (true);
- }
- }
- }
-
-
- int hashcode = ch % TOKEN_HASH_SIZE;
- int hashProbe = 1 + ch % SECOND_PRIME;
- int remaining = str.len - str.Index;
- int i = 0;
-
- TokenHashValue[] hashTable = m_dtfiTokenHash;
- if (hashTable == null) {
- hashTable = CreateTokenHashTable();
- }
- do {
- value = hashTable[hashcode];
- if (value == null) {
-
- break;
- }
-
- if (((int)value.tokenType & (int)TokenMask) > 0 && value.tokenString.Length <= remaining) {
- if (String.Compare(str.Value, str.Index, value.tokenString, 0, value.tokenString.Length, true, CultureInfo.CurrentCulture) == 0) {
- if (isLetter) {
-
- int nextCharIndex;
- if ((nextCharIndex = str.Index + value.tokenString.Length) < str.len) {
-
- char nextCh = str.Value[nextCharIndex];
- if (Char.IsLetter(nextCh)) {
- return (false);
- }
- }
- }
- tokenType = value.tokenType & TokenMask;
- tokenValue = value.tokenValue;
- str.Advance(value.tokenString.Length);
- return (true);
- }
- else if (value.tokenType == TokenType.MonthToken && HasSpacesInMonthNames) {
-
- int matchStrLen = 0;
- if (str.MatchSpecifiedWords(value.tokenString, true, ref matchStrLen)) {
- tokenType = value.tokenType & TokenMask;
- tokenValue = value.tokenValue;
- str.Advance(matchStrLen);
- return (true);
- }
- }
- else if (value.tokenType == TokenType.DayOfWeekToken && HasSpacesInDayNames) {
-
- int matchStrLen = 0;
- if (str.MatchSpecifiedWords(value.tokenString, true, ref matchStrLen)) {
- tokenType = value.tokenType & TokenMask;
- tokenValue = value.tokenValue;
- str.Advance(matchStrLen);
- return (true);
- }
- }
- }
- i++;
- hashcode += hashProbe;
- if (hashcode >= TOKEN_HASH_SIZE)
- hashcode -= TOKEN_HASH_SIZE;
- }
- while (i < TOKEN_HASH_SIZE);
-
- return (false);
- }
-
- void InsertAtCurrentHashNode(TokenHashValue[] hashTable, string str, char ch, TokenType tokenType, int tokenValue, int pos, int hashcode, int hashProbe)
- {
-
- TokenHashValue previousNode = hashTable[hashcode];
-
- //// Console.WriteLine(" Insert Key: {0} in {1}", str, slotToInsert);
-
- hashTable[hashcode] = new TokenHashValue(str, tokenType, tokenValue);
- ;
-
- while (++pos < TOKEN_HASH_SIZE) {
- hashcode += hashProbe;
- if (hashcode >= TOKEN_HASH_SIZE)
- hashcode -= TOKEN_HASH_SIZE;
-
- TokenHashValue temp = hashTable[hashcode];
-
- if (temp != null && Char.ToLower(temp.tokenString[0], CultureInfo.CurrentCulture) != ch) {
- continue;
- }
-
- hashTable[hashcode] = previousNode;
- //// Console.WriteLine(" Move {0} to slot {1}", previousNode.tokenString, hashcode);
- if (temp == null) {
-
- return;
- }
- previousNode = temp;
- }
- ;
- BCLDebug.Assert(true, "The hashtable is full. This should not happen.");
- }
-
- void InsertHash(TokenHashValue[] hashTable, string str, TokenType tokenType, int tokenValue)
- {
-
- if (str == null || str.Length == 0) {
- return;
- }
- TokenHashValue value;
- int i = 0;
-
-
- if (Char.IsWhiteSpace(str[0]) || Char.IsWhiteSpace(str[str.Length - 1])) {
- str = str.Trim(null);
-
- }
- char ch = Char.ToLower(str[0], CultureInfo.CurrentCulture);
- int hashcode = ch % TOKEN_HASH_SIZE;
- int hashProbe = 1 + ch % SECOND_PRIME;
- do {
- value = hashTable[hashcode];
- if (value == null) {
- //// Console.WriteLine(" Put Key: {0} in {1}", str, hashcode);
- hashTable[hashcode] = new TokenHashValue(str, tokenType, tokenValue);
- return;
- }
- else {
-
- if (str.Length >= value.tokenString.Length) {
-
-
- if (String.Compare(str, 0, value.tokenString, 0, value.tokenString.Length, true, CultureInfo.CurrentCulture) == 0) {
- if (str.Length > value.tokenString.Length) {
-
-
- InsertAtCurrentHashNode(hashTable, str, ch, tokenType, tokenValue, i, hashcode, hashProbe);
- return;
- }
- else {
-
- if (((int)tokenType & 65280) != ((int)value.tokenType & 65280)) {
- value.tokenType |= tokenType;
- if (tokenValue != 0) {
- value.tokenValue = tokenValue;
- }
- }
-
- }
- }
- }
- }
- //// Console.WriteLine(" COLLISION. Old Key: {0}, New Key: {1}", hashTable[hashcode].tokenString, str);
- i++;
- hashcode += hashProbe;
- if (hashcode >= TOKEN_HASH_SIZE)
- hashcode -= TOKEN_HASH_SIZE;
- }
- while (i < TOKEN_HASH_SIZE);
- BCLDebug.Assert(true, "The hashtable is full. This should not happen.");
- }
-
- static internal string GetCalendarInfo(int culture, int calendar, int calType)
- {
- int size = Microsoft.Win32.Win32Native.GetCalendarInfo(culture, calendar, calType, null, 0, IntPtr.Zero);
- if (size > 0) {
- StringBuilder buffer = new StringBuilder(size);
- size = Microsoft.Win32.Win32Native.GetCalendarInfo(culture, calendar, calType, buffer, size, IntPtr.Zero);
- if (size > 0)
- return buffer.ToString(0, size - 1);
-
- }
- return null;
- }
-
-
- internal const int CAL_SCALNAME = 2;
-
- }
-
- internal class TokenHashValue
- {
- internal string tokenString;
- internal TokenType tokenType;
- internal int tokenValue;
-
- internal TokenHashValue(string tokenString, TokenType tokenType, int tokenValue)
- {
- this.tokenString = tokenString;
- this.tokenType = tokenType;
- this.tokenValue = tokenValue;
- }
- }
- }