任何人都可以告诉我如何在此代码上实现DateTime
?试图谷歌,但仍然混淆这个代码。
public double CalcLastCouponDate(DateTime dtmBaseDate, DateTime dtmLastDate, int intCouponTermMonths, int intFixedCouponDay, string strOddLastCouponType)
{
int i = 0;
DateTime dtmLastCoupon;
{
if (strOddLastCouponType == "S")
{
return dtmLastCoupon = DateAdd("M", -intCouponTermMonths, dtmLastCoupon); // How to convert DateAdd to C#
}
else
{
return dtmLastCoupon = DateAdd("M", -2 * intCouponTermMonths, dtmLastCoupon); // How to convert DateAdd to C#
}
}
}
public bool IsEndDayofMonth(DateTime DateIn)
{
int intLastDay = 0;
bool IsEndDay = false;
intLastDay = CalcEndDayofMonth(Year(DateIn), Month(DateIn)); // Convert Year, Month to C#
if (intLastDay == Day(DateIn)) // Convert Day to C#
{
IsEndDay = true;
}
else
{
IsEndDay = false;
}
return IsEndDay;
答案 0 :(得分:1)
假设DateAdd具有正常的语义,它可能看起来像这样:
public DateTime CalcLastCouponDate(DateTime dtmBaseDate, DateTime dtmLastDate, int intCouponTermMonths, int intFixedCouponDay, string strOddLastCouponType)
{
return (strOddLastCouponType == "S") ?
dtmLastDate.AddMonths(-intCouponTermMonths) :
dtmLastDate.AddMonths(-2 * intCouponTermMonths);
}
public bool IsLastDayOfMonth(DateTime dateIn)
{
return dateIn.Day == DateTime.DaysInMonth(dateIn.Year, dateIn.Month);
}
等
答案 1 :(得分:0)