[Quantproject-developers] QuantProject/b1_ADT/Timing Time.cs, 1.4, 1.5
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-12-10 19:42:59
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14611/b1_ADT/Timing Modified Files: Time.cs Log Message: - automatic indentation has been applied - a new method public static void CheckStrictlyAscending( List< Time > times ) has been added Index: Time.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Timing/Time.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Time.cs 20 Nov 2008 20:37:59 -0000 1.4 --- Time.cs 10 Dec 2008 19:42:48 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.Collections.Generic; namespace QuantProject.ADT.Timing *************** *** 36,70 **** bool returnValue = false; char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; return returnValue; --- 37,71 ---- bool returnValue = false; char[] chars = stringRepresentingTime.ToCharArray(); ! if( ! //first - hour ! (chars[0]=='0' || chars[0]=='1' || chars[0]=='2') && ! //second - hour ! ( (chars[0]=='0' || chars[0]=='1') && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4' || chars[1]=='5' || ! chars[1]=='6' || chars[1]=='7' || chars[1]=='8' || chars[1]=='9') || ! chars[0] == '2' && ! (chars[1]=='0' || chars[1]=='1' || chars[1]=='2' || ! chars[1]=='3' || chars[1]=='4') ) && ! //third - separator ! (chars[2]==':') && ! //fourth - minute ! (chars[3]=='0' || chars[3]=='1' || chars[3]=='2' || ! chars[3]=='3' || chars[3]=='4' || chars[3]=='5') && ! //fifth - minute ! (chars[4]=='0' || chars[4]=='1' || chars[4]=='2' || ! chars[4]=='3' || chars[4]=='4' || chars[4]=='5' || ! chars[4]=='6' || chars[4]=='7' || chars[4]=='8' || chars[4]=='9') && ! //sixth - separator ! (chars[5]==':') && ! //seventh - second ! (chars[6]=='0' || chars[6]=='1' || chars[6]=='2' || ! chars[6]=='3' || chars[6]=='4' || chars[6]=='5') && ! //eighth - second ! (chars[7]=='0' || chars[7]=='1' || chars[7]=='2' || ! chars[7]=='3' || chars[7]=='4' || chars[7]=='5' || ! chars[7]=='6' || chars[7]=='7' || chars[7]=='8' || chars[7]=='9') ! ) ! returnValue = true; return returnValue; *************** *** 83,87 **** { return new DateTime( dateTime.Year , dateTime.Month , dateTime.Day, ! time.Hour , time.Minute , time.Second ); } --- 84,88 ---- { return new DateTime( dateTime.Year , dateTime.Month , dateTime.Day, ! time.Hour , time.Minute , time.Second ); } *************** *** 127,132 **** private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } --- 128,133 ---- private void time_checkParameter ( string stringRepresentingTime ) { ! if( stringRepresentingTime.Length != 8 || ! !Time.IsValidTimeFormat( stringRepresentingTime ) ) throw new Exception("string is not in the requested time-format hh:mm:ss"); } *************** *** 141,145 **** //just for compiling next two lines this.time_checkParameter( stringRepresentingTime ); ! this.standardDateTime = this.time_getStandardTimeFromString( stringRepresentingTime ); } --- 142,146 ---- //just for compiling next two lines this.time_checkParameter( stringRepresentingTime ); ! this.standardDateTime = this.time_getStandardTimeFromString( stringRepresentingTime ); } *************** *** 231,234 **** --- 232,252 ---- return returnValue; } + + #region CheckStrictlyAscending + private static void checkStrictlyAscending( + List< Time > times , int timeIndex ) + { + Time currentTime = times[ timeIndex ]; + Time nextTime = times[ timeIndex + 1 ]; + if ( currentTime >= nextTime ) + throw new Exception( + "Given times are not in strict ascending order" ); + } + public static void CheckStrictlyAscending( List< Time > times ) + { + for ( int i = 0 ; i < times.Count - 1 ; i++ ) + Time.checkStrictlyAscending( times , i ); + } + #endregion CheckStrictlyAscending } } |