[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed partial class DateTimeFormatInfo : IFormatProvider, ICloneable
{
// cache for the invariant culture.
}
}
-
// Note that cultureData derives this from the short date format (unless someone's set this previously)
// Note that this property is quite undesirable.
- internal String DateSeparator
+ public string DateSeparator
{
get
{
- if (this.dateSeparator == null)
+ if (dateSeparator == null)
{
- this.dateSeparator = _cultureData.DateSeparator(Calendar.ID);
+ dateSeparator = _cultureData.DateSeparator(Calendar.ID);
}
Contract.Assert(this.dateSeparator != null, "DateTimeFormatInfo.DateSeparator, dateSeparator != null");
- return (this.dateSeparator);
+ return dateSeparator;
}
+
set
{
- throw null;
+ if (IsReadOnly)
+ throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
+
+ if (value == null)
+ {
+ throw new ArgumentNullException("value", SR.ArgumentNull_String);
+ }
+ Contract.EndContractBlock();
+ ClearTokenHashTable();
+ dateSeparator = value;
}
}
-
public DayOfWeek FirstDayOfWeek
{
get
// Note that cultureData derives this from the long time format (unless someone's set this previously)
// Note that this property is quite undesirable.
- internal String TimeSeparator
+ public string TimeSeparator
{
get
{
set
{
- throw null;
+ if (IsReadOnly)
+ throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
+
+ if (value == null)
+ {
+ throw new ArgumentNullException("value", SR.ArgumentNull_String);
+ }
+
+ Contract.EndContractBlock();
+ ClearTokenHashTable();
+
+ timeSeparator = value;
}
}
-
public String UniversalSortableDateTimePattern
{
get
}
// Returns the string array of the one-letter day of week names.
- [System.Runtime.InteropServices.ComVisible(false)]
public String[] ShortestDayNames
{
get
return (internalGetAbbreviatedDayOfWeekNames()[(int)dayofweek]);
}
+ // Returns the super short day of week names for the specified day of week.
+ public string GetShortestDayName(DayOfWeek dayOfWeek)
+ {
+ if ((int)dayOfWeek < 0 || (int)dayOfWeek > 6)
+ {
+ throw new ArgumentOutOfRangeException(
+ "dayOfWeek", SR.Format(SR.ArgumentOutOfRange_Range,
+ DayOfWeek.Sunday, DayOfWeek.Saturday));
+ }
+ Contract.EndContractBlock();
+ //
+ // Don't call the public property SuperShortDayNames here since a clone is needed in that
+ // property, so it will be slower. Instead, use internalGetSuperShortDayNames() directly.
+ //
+ return (internalGetSuperShortDayNames()[(int)dayOfWeek]);
+ }
+
// Get all possible combination of inputs
private static String[] GetCombinedPatterns(String[] patterns1, String[] patterns2, String connectString)
{
return (result);
}
+ public string[] GetAllDateTimePatterns()
+ {
+ List<String> results = new List<String>(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]);
+ }
+ }
+ return results.ToArray();
+ }
- // auto-generated
- internal String[] GetAllDateTimePatterns(char format)
+ public string[] GetAllDateTimePatterns(char format)
{
Contract.Ensures(Contract.Result<String[]>() != null);
String[] result = null;
}
}
- [System.Runtime.InteropServices.ComVisible(false)]
+ // Return the native name for the calendar in DTFI.Calendar. The native name is referred to
+ // the culture used to create the DTFI. E.g. in the following example, the native language is Japanese.
+ // DateTimeFormatInfo dtfi = new CultureInfo("ja-JP", false).DateTimeFormat.Calendar = new JapaneseCalendar();
+ // String nativeName = dtfi.NativeCalendarName; // Get the Japanese name for the Japanese calendar.
+ // DateTimeFormatInfo dtfi = new CultureInfo("ja-JP", false).DateTimeFormat.Calendar = new GregorianCalendar(GregorianCalendarTypes.Localized);
+ // String nativeName = dtfi.NativeCalendarName; // Get the Japanese name for the Gregorian calendar.
+ public string NativeCalendarName
+ {
+ get
+ {
+ return _cultureData.CalendarName(Calendar.ID);
+ }
+ }
+
+ //
+ // Used by custom cultures and others to set the list of available formats. Note that none of them are
+ // explicitly used unless someone calls GetAllDateTimePatterns and subsequently uses one of the items
+ // from the list.
+ //
+ // Most of the format characters that can be used in GetAllDateTimePatterns are
+ // not really needed since they are one of the following:
+ //
+ // r/R/s/u locale-independent constants -- cannot be changed!
+ // m/M/y/Y fields with a single string in them -- that can be set through props directly
+ // f/F/g/G/U derived fields based on combinations of various of the below formats
+ //
+ // NOTE: No special validation is done here beyond what is done when the actual respective fields
+ // are used (what would be the point of disallowing here what we allow in the appropriate property?)
+ //
+ // WARNING: If more validation is ever done in one place, it should be done in the other.
+ //
+ public void SetAllDateTimePatterns(String[] patterns, char format)
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException(SR.InvalidOperation_ReadOnly);
+
+ if (patterns == null)
+ {
+ throw new ArgumentNullException("patterns", SR.ArgumentNull_Array);
+ }
+
+ if (patterns.Length == 0)
+ {
+ throw new ArgumentException(SR.Arg_ArrayZeroError, "patterns");
+ }
+
+ Contract.EndContractBlock();
+
+ for (int i=0; i<patterns.Length; i++)
+ {
+ if (patterns[i] == null)
+ {
+ throw new ArgumentNullException("patterns[" + i + "]", SR.ArgumentNull_ArrayValue);
+ }
+ }
+
+ // Remember the patterns, and use the 1st as default
+ switch (format)
+ {
+ case 'd':
+ allShortDatePatterns = patterns;
+ shortDatePattern = allShortDatePatterns[0];
+ break;
+
+ case 'D':
+ allLongDatePatterns = patterns;
+ longDatePattern = allLongDatePatterns[0];
+ break;
+
+ case 't':
+ allShortTimePatterns = patterns;
+ shortTimePattern = allShortTimePatterns[0];
+ break;
+
+ case 'T':
+ allLongTimePatterns = patterns;
+ longTimePattern = allLongTimePatterns[0];
+ break;
+
+ case 'y':
+ case 'Y':
+ allYearMonthPatterns = patterns;
+ yearMonthPattern = allYearMonthPatterns[0];
+ break;
+
+ default:
+ throw new ArgumentException(SR.Format_BadFormatSpecifier, "format");
+ }
+
+ // Clear the token hash table, note that even short dates could require this
+ ClearTokenHashTable();
+ }
+
public String[] AbbreviatedMonthGenitiveNames
{
get
}
}
- [System.Runtime.InteropServices.ComVisible(false)]
public String[] MonthGenitiveNames
{
get