Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSureshkumar T <suresh@mono-cvs.ximian.com>2005-02-03 12:28:48 +0300
committerSureshkumar T <suresh@mono-cvs.ximian.com>2005-02-03 12:28:48 +0300
commit8d01baf2704f8ae36eac20ac03110bb38cbfb0b8 (patch)
treecb54b969430c9734f37de20f25e6fbe16a0a0a34 /mcs/class/System.Data/System.Data.SqlTypes
parenta343b2fa9b5699b4cdb3f87e40c16f79574672d1 (diff)
2005-02-03 Sureshkumar T <tsureshkumar@novell.com>
* SqlDateTime.cs : Parse : try with local culture first, then try with invariant culture if it fails. svn path=/trunk/mcs/; revision=40036
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlTypes')
-rw-r--r--mcs/class/System.Data/System.Data.SqlTypes/ChangeLog5
-rw-r--r--mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs14
2 files changed, 18 insertions, 1 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
index 0275218e17c..0eaabeacc8e 100644
--- a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
+++ b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
@@ -1,3 +1,8 @@
+2005-02-03 Sureshkumar T <tsureshkumar@novell.com>
+
+ * SqlDateTime.cs : Parse : try with local culture first, then try
+ with invariant culture if it fails.
+
2004-09-14 Umadevi S <sumadevi@novell.com>
* Made SerializableAttribute !net_2_0 for all the exception classes
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs b/mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs
index 24634b1d0f7..62802dbe4d0 100644
--- a/mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs
+++ b/mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs
@@ -236,7 +236,19 @@ namespace System.Data.SqlTypes
public static SqlDateTime Parse (string s)
{
- return new SqlDateTime (DateTime.Parse (s));
+ if (s == null)
+ throw new ArgumentNullException ("Argument cannot be null");
+
+ // try parsing in local culture
+ DateTimeFormatInfo fmtInfo = DateTimeFormatInfo.CurrentInfo;
+ try {
+ return new SqlDateTime (DateTime.Parse (s, fmtInfo));
+ } catch (Exception e) {
+ // try parsing in invariant culture
+ return new SqlDateTime (DateTime.Parse (s, CultureInfo.InvariantCulture));
+ }
+ throw new FormatException (String.Format ("String {0} is not recognized as "+
+ " valid DateTime.", s));
}
public SqlString ToSqlString ()