[Quantproject-developers] QuantProject/b1_ADT ExtendedDateTime.cs, 1.8, 1.9
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2011-08-21 09:59:14
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT
In directory vz-cvs-3.sog:/tmp/cvs-serv26129
Modified Files:
ExtendedDateTime.cs
Log Message:
Added GetLastDateOfTheLastQuarter method
Index: ExtendedDateTime.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ExtendedDateTime.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ExtendedDateTime.cs 8 Nov 2008 20:27:25 -0000 1.8
--- ExtendedDateTime.cs 21 Aug 2011 09:59:11 -0000 1.9
***************
*** 170,173 ****
--- 170,210 ----
return isFirstTimeLessThenSecondTime;
}
+
+ /// <summary>
+ /// Returns the last date of the last quarter
+ /// </summary>
+ /// <param name="dateTime"></param>
+ /// <returns></returns>
+ public static DateTime GetLastDateOfTheLastQuarter( DateTime dateTime )
+ {
+ DateTime lastDateOfLastQuarter;
+ int currentMonth = dateTime.Month;
+ int year_lastDateOfLastQuarter = dateTime.Year;
+ int month_lastDateOfLastQuarter = 12;
+ int day_lastDateOfLastQuarter = 31;
+
+ if ( currentMonth >= 1 && currentMonth <=3 )
+ {
+ year_lastDateOfLastQuarter = dateTime.Year - 1;
+ }
+ else if ( currentMonth >= 4 && currentMonth <=6 )
+ {
+ month_lastDateOfLastQuarter = 3;
+ }
+ else if ( currentMonth >= 7 && currentMonth <=9 )
+ {
+ month_lastDateOfLastQuarter = 6;
+ day_lastDateOfLastQuarter = 30;
+ }
+ else if ( currentMonth >= 10 && currentMonth <=12 )
+ {
+ month_lastDateOfLastQuarter = 9;
+ day_lastDateOfLastQuarter = 30;
+ }
+ lastDateOfLastQuarter =
+ new DateTime(year_lastDateOfLastQuarter, month_lastDateOfLastQuarter,
+ day_lastDateOfLastQuarter, 16, 0, 0);
+ return lastDateOfLastQuarter;
+ }
}
}
|