{
var sResult,sTemp,i ;
var iInt ; // 整数部分
var iDig ; // 小数部分
if (iDec <= 0) //保留的小数点位数小于或等于0
{
sResult = Math.round(rNumber) ;
}
else
{
iInt = Math.floor(rNumber) ;
iDig = rNumber - iInt ;
iDig = Math.round(iDig * Math.pow(10,iDec)) ;
if (iDig >= Math.pow(10,iDec)) // 当小数点部分四舍五入后向整数位进位时
{
iInt = iInt + 1 ;
iDig = 0 ;
}
if (iDig == 0) // 当小数点部分为0是补0
{
sTemp = "" ;
for (i = 1;i <= iDec ; i++) { sTemp = sTemp + ''0''; }
sResult = iInt + "." + sTemp ;
}
else
{
if (iDig < Math.pow(10,iDec - 1))
{
sTemp = "" ;
for (i = 1 ; i <= iDec - 1 ; i ++)
{
if (iDig < Math.pow(10,i)) { sTemp = sTemp + "0" ; }
}
sResult = iInt + "." + sTemp + iDig ;
}
else
{
sResult = iInt + "." + iDig ;
}
}
}
return sResult ;
}
// ==================================================================================
// 第二部分 日期相关函数
// ==================================================================================
// ----------------------------------------------------------------------------------
//2.1 本函数用于用于求解iYear年iMonth月份的天数
// ----------------------------------------------------------------------------------
function JGetDays(iYear,iMonth)
{
var StartDate,EndDate,iStart,iEnd,iDays ;
switch (iMonth)
{
case 1: return 31 ;
case 3: return 31 ;
case 5: return 31 ;
case 7: return 31 ;
case 8: return 31 ;
case 10: return 31 ;
case 12: return 31 ;
case 4: return 30;
case 6: return 30;
case 9: return 30;
case 11: return 30;
case 2:
StartDate = new Date(iYear,1 ,1) ;
iStart = StartDate.getTime() ;
EndDate = new Date(iYear,2,1) ;
iEnd = EndDate.getTime() ;
iDays = iEnd - iStart ;
iDays = iDays / 1000 / 60 / 60 / 24 ;










