[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization DateTim
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization DateTimeFormatInfo.cs,1.6,1.7 |
Date: |
Sat, 29 Mar 2003 19:59:36 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization
In directory subversions:/tmp/cvs-serv12323/runtime/System/Globalization
Modified Files:
DateTimeFormatInfo.cs
Log Message:
Handle era name values; return the full date/time format list.
Index: DateTimeFormatInfo.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/DateTimeFormatInfo.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** DateTimeFormatInfo.cs 29 Nov 2002 18:29:59 -0000 1.6
--- DateTimeFormatInfo.cs 30 Mar 2003 00:59:34 -0000 1.7
***************
*** 37,40 ****
--- 37,42 ----
private String[] abbreviatedMonthNames;
private String[] monthNames;
+ private String[] eraNames;
+ private String[] abbrevEraNames;
private String dateSeparator;
private String timeSeparator;
***************
*** 46,53 ****
private String shortTimePattern;
private String yearMonthPattern;
- #if !ECMA_COMPAT
private Calendar calendar;
private CalendarWeekRule calendarWeekRule;
private DayOfWeek firstDayOfWeek;
#endif // !ECMA_COMPAT
--- 48,56 ----
private String shortTimePattern;
private String yearMonthPattern;
private Calendar calendar;
+ #if !ECMA_COMPAT
private CalendarWeekRule calendarWeekRule;
private DayOfWeek firstDayOfWeek;
+ private String[] dateTimePatterns;
#endif // !ECMA_COMPAT
***************
*** 72,75 ****
--- 75,111 ----
"December", ""};
+ // Invariant era names.
+ private static readonly String[] invEraNames = {"A.D."};
+ private static readonly String[] invAbbrevEraNames = {"AD"};
+
+ // Invariant date time pattern list.
+ private static readonly String[] invDateTimePatterns =
+ {"MM/dd/yyyy",
+ "dddd, dd MMMM yyyy",
+ "dddd, dd MMMM yyyy HH:mm",
+ "dddd, dd MMMM yyyy hh:mm tt",
+ "dddd, dd MMMM yyyy H:mm",
+ "dddd, dd MMMM yyyy h:mm tt",
+ "dddd, dd MMMM yyyy HH:mm:ss",
+ "MM/dd/yyyy HH:mm",
+ "MM/dd/yyyy hh:mm tt",
+ "MM/dd/yyyy H:mm",
+ "MM/dd/yyyy h:mm tt",
+ "MM/dd/yyyy HH:mm:ss",
+ "MMMM dd",
+ "MMMM dd",
+ "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'",
+ "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'",
+ "yyyy'-'MM'-'dd'T'HH':'mm':'ss",
+ "HH:mm",
+ "hh:mm tt",
+ "H:mm",
+ "h:mm tt",
+ "HH:mm:ss",
+ "yyyy'-'MM'-'dd HH':'mm':'ss'Z'",
+ "dddd, dd MMMM yyyy HH:mm:ss",
+ "yyyy MMMM",
+ "yyyy MMMM"};
+
// Constructor.
public DateTimeFormatInfo()
***************
*** 82,85 ****
--- 118,123 ----
abbreviatedMonthNames = invAbbrevMonthNames;
monthNames = invMonthNames;
+ eraNames = invEraNames;
+ abbrevEraNames = invAbbrevEraNames;
dateSeparator = "/";
timeSeparator = ":";
***************
*** 91,98 ****
shortTimePattern = "HH:mm";
yearMonthPattern = "yyyy MMMM";
- #if !ECMA_COMPAT
calendar = new GregorianCalendar();
calendarWeekRule = CalendarWeekRule.FirstDay;
firstDayOfWeek = DayOfWeek.Sunday;
#endif // !ECMA_COMPAT
}
--- 129,137 ----
shortTimePattern = "HH:mm";
yearMonthPattern = "yyyy MMMM";
calendar = new GregorianCalendar();
+ #if !ECMA_COMPAT
calendarWeekRule = CalendarWeekRule.FirstDay;
firstDayOfWeek = DayOfWeek.Sunday;
+ dateTimePatterns = invDateTimePatterns;
#endif // !ECMA_COMPAT
}
***************
*** 144,161 ****
}
// Get a value that represents an era name.
- [TODO]
public int GetEra(String eraName)
{
! // TODO
! return -1;
}
// Get the name of a particular era.
- [TODO]
public String GetEraName(int era)
{
! // TODO: support other Calendars as well
! return "AD";
}
--- 183,244 ----
}
+ // Search for an era name within an array.
+ private static int SearchForEra(String[] names, String name)
+ {
+ int posn;
+ if(names == null)
+ {
+ return -1;
+ }
+ for(posn = 0; posn < names.Length; ++posn)
+ {
+ if(String.Compare(names[posn], name,
true) == 0)
+ {
+ return posn + 1;
+ }
+ }
+ return -1;
+ }
+
// Get a value that represents an era name.
public int GetEra(String eraName)
{
! int era;
! if(eraName == null)
! {
! throw new
ArgumentNullException("eraName");
! }
! era = SearchForEra(eraNames, eraName);
! if(era == -1)
! {
! era = SearchForEra(abbrevEraNames,
eraName);
! }
! if(era == -1)
! {
! era = SearchForEra(invEraNames,
eraName);
! }
! if(era == -1)
! {
! era = SearchForEra(invAbbrevEraNames,
eraName);
! }
! return era;
}
// Get the name of a particular era.
public String GetEraName(int era)
{
! if(era ==
System.Globalization.Calendar.CurrentEra)
! {
! era = Calendar.GetEra(DateTime.Now);
! }
! if(era >= 1 && era <= eraNames.Length)
! {
! return eraNames[era - 1];
! }
! else
! {
! throw new ArgumentOutOfRangeException
! ("era", _("Arg_InvalidEra"));
! }
}
***************
*** 259,277 ****
// Get the abbreviated name of an era.
- [TODO]
public String GetAbbreviatedEraName(int era)
{
! // TODO
! return null;
}
// Get all date time patterns.
- [TODO]
public String[] GetAllDateTimePatterns()
{
! // TODO
! String[] array = new String [1];
! array[0] = FullDateTimePattern;
! return array;
}
[TODO]
--- 342,371 ----
// Get the abbreviated name of an era.
public String GetAbbreviatedEraName(int era)
{
! if(abbrevEraNames == null)
! {
! // Use the full name if there are no
abbreviated names.
! return GetEraName(era);
! }
! if(era ==
System.Globalization.Calendar.CurrentEra)
! {
! era = Calendar.GetEra(DateTime.Now);
! }
! if(era >= 1 && era <= abbrevEraNames.Length)
! {
! return abbrevEraNames[era - 1];
! }
! else
! {
! throw new ArgumentOutOfRangeException
! ("era", _("Arg_InvalidEra"));
! }
}
// Get all date time patterns.
public String[] GetAllDateTimePatterns()
{
! return (String[])(dateTimePatterns.Clone());
}
[TODO]
***************
*** 613,620 ****
}
! #if !ECMA_COMPAT
!
! // Non-ECMA properties.
! public Calendar Calendar
{
get
--- 707,717 ----
}
! // Get or set the calendar in use by this date/time formatting object.
! #if ECMA_COMPAT
! internal
! #else
! public
! #endif
! Calendar Calendar
{
get
***************
*** 669,672 ****
--- 766,773 ----
}
}
+
+ #if !ECMA_COMPAT
+
+ // Non-ECMA properties.
public CalendarWeekRule CalendarWeekRule
{
***************
*** 749,752 ****
--- 850,871 ----
}
}
+ }
+
+ // Set the era name lists - this should not be used by applications.
+ // It exists to support I18N plugins, which have no other way to
+ // set this information through the published API's.
+ public void I18NSetEraNames(String[] names, String[] abbrevNames)
+ {
+ if(names == null)
+ {
+ throw new
ArgumentNullException("names");
+ }
+ CheckForNulls(names);
+ if(abbrevNames != null)
+ {
+ CheckForNulls(abbrevNames);
+ }
+ eraNames = names;
+ abbrevEraNames = abbrevNames;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization DateTimeFormatInfo.cs,1.6,1.7,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Text UTF8Encoding.cs,1.8,1.9 UnicodeEncoding.cs,1.9,1.10
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.769,1.770
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Text UTF8Encoding.cs,1.8,1.9 UnicodeEncoding.cs,1.9,1.10
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.769,1.770
- Index(es):