dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] pnetlib/runtime/System/Private/DateTimeFormat Date


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnetlib/runtime/System/Private/DateTimeFormat DateTimeParser.cs, 1.4, 1.5
Date: Sun, 23 Nov 2003 21:51:44 +0000

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/DateTimeFormat
In directory 
subversions:/tmp/cvs-serv27740/runtime/System/Private/DateTimeFormat

Modified Files:
        DateTimeParser.cs 
Log Message:


Parse numeric fields with a maximum digit count, so that
"yyyyMMdd" formats can be processed correctly (bug #6682).


Index: DateTimeParser.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Private/DateTimeFormat/DateTimeParser.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DateTimeParser.cs   3 Jun 2003 03:26:47 -0000       1.4
--- DateTimeParser.cs   23 Nov 2003 21:51:42 -0000      1.5
***************
*** 38,42 ****
  
        // Parse a decimal number from a string.
!       private static int ParseNumber(String s, ref int posn)
                        {
                                int value;
--- 38,42 ----
  
        // Parse a decimal number from a string.
!       private static int ParseNumber(String s, ref int posn, int maxDigits)
                        {
                                int value;
***************
*** 50,56 ****
  
                                // Recognize additional digits.
!                               while(posn < s.Length && s[posn] >= '0' && 
s[posn] <= '9')
                                {
                                        value = (value * 10) + (int)(s[posn++] 
- '0');
                                }
  
--- 50,58 ----
  
                                // Recognize additional digits.
!                               while(maxDigits > 1 && posn < s.Length && 
s[posn] >= '0'
!                                     && s[posn] <= '9')
                                {
                                        value = (value * 10) + (int)(s[posn++] 
- '0');
+                                       --maxDigits;
                                }
  
***************
*** 150,154 ****
  
                                // Parse the hour portion of the timezone.
!                               hour = ParseNumber(s, ref posn);
  
                                // Parse the minute portion if there is a ':' 
separator.
--- 152,156 ----
  
                                // Parse the hour portion of the timezone.
!                               hour = ParseNumber(s, ref posn, 2);
  
                                // Parse the minute portion if there is a ':' 
separator.
***************
*** 156,160 ****
                                {
                                        ++posn;
!                                       minute = ParseNumber(s, ref posn);
                                }
                                else
--- 158,162 ----
                                {
                                        ++posn;
!                                       minute = ParseNumber(s, ref posn, 2);
                                }
                                else
***************
*** 320,324 ****
                                                        if(count == 1 || count 
== 2)
                                                        {
!                                                               day = 
ParseNumber(s, ref sposn);
                                                        }
                                                        else if(count == 3)
--- 322,326 ----
                                                        if(count == 1 || count 
== 2)
                                                        {
!                                                               day = 
ParseNumber(s, ref sposn, 2);
                                                        }
                                                        else if(count == 3)
***************
*** 339,343 ****
                                                        if(count == 1 || count 
== 2)
                                                        {
!                                                               month = 
ParseNumber(s, ref sposn);
                                                        }
                                                        else if(count == 3)
--- 341,345 ----
                                                        if(count == 1 || count 
== 2)
                                                        {
!                                                               month = 
ParseNumber(s, ref sposn, 2);
                                                        }
                                                        else if(count == 3)
***************
*** 360,368 ****
                                                        {
                                                                year = 
calendar.ToFourDigitYear
!                                                                       
(ParseNumber(s, ref sposn));
                                                        }
                                                        else
                                                        {
!                                                               year = 
ParseNumber(s, ref sposn);
                                                        }
                                                }
--- 362,370 ----
                                                        {
                                                                year = 
calendar.ToFourDigitYear
!                                                                       
(ParseNumber(s, ref sposn, 2));
                                                        }
                                                        else
                                                        {
!                                                               year = 
ParseNumber(s, ref sposn, 4);
                                                        }
                                                }
***************
*** 379,383 ****
                                                {
                                                        // Parse the hour in 
12-hour format.
!                                                       hour = ParseNumber(s, 
ref sposn);
                                                }
                                                break;
--- 381,385 ----
                                                {
                                                        // Parse the hour in 
12-hour format.
!                                                       hour = ParseNumber(s, 
ref sposn, 2);
                                                }
                                                break;
***************
*** 386,390 ****
                                                {
                                                        // Parse the hour in 
24-hour format.
!                                                       hour = ParseNumber(s, 
ref sposn);
                                                }
                                                break;
--- 388,392 ----
                                                {
                                                        // Parse the hour in 
24-hour format.
!                                                       hour = ParseNumber(s, 
ref sposn, 2);
                                                }
                                                break;
***************
*** 393,397 ****
                                                {
                                                        // Parse the minute.
!                                                       minute = ParseNumber(s, 
ref sposn);
                                                }
                                                break;
--- 395,399 ----
                                                {
                                                        // Parse the minute.
!                                                       minute = ParseNumber(s, 
ref sposn, 2);
                                                }
                                                break;
***************
*** 400,404 ****
                                                {
                                                        // Parse the second.
!                                                       second = ParseNumber(s, 
ref sposn);
                                                }
                                                break;
--- 402,406 ----
                                                {
                                                        // Parse the second.
!                                                       second = ParseNumber(s, 
ref sposn, 2);
                                                }
                                                break;
***************
*** 407,411 ****
                                                {
                                                        // Parse fractions of a 
second.
!                                                       fractions = 
ParseNumber(s, ref sposn);
                                                        while(count < 7)
                                                        {
--- 409,414 ----
                                                {
                                                        // Parse fractions of a 
second.
!                                                       fractions = 
ParseNumber(s, ref sposn,
!                                                                               
                        Int32.MaxValue);
                                                        while(count < 7)
                                                        {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]