Round: function (x, y) {
///<summary>Method to round decimal no. to given no. of positions</summary>
/// <param name="x" >
/// Input decimal value
/// </param>
///<param name="y" >
/// No. of decimal points to be restricted
/// </param>
return Math.round(x * Math.pow(10, y)) / Math.pow(10, y);
//return parseFloat(x).toFixed(y);
},
RoundTime: function (x, y) {
///<summary>Method to round decimal no. to given no. of positions</summary>
/// <param name="x" >
/// Input decimal value
/// </param>
///<param name="y" >
/// No. of decimal points to be restricted
/// </param>
var time = x;
var timeArr = String(time).split('.');
var hrs = timeArr[0];
var min = 0;
if (parseFloat(timeArr[1]) > 0) {
min = 60 * parseFloat(timeArr[1]);
}
//var minArr = String(min).split('.');
var convertmin = parseFloat(min) / 10000000000000000;
if (parseFloat(convertmin) > 0) {
if (parseFloat(convertmin) < 1) {
return hrs + ".0" + ERPScriptUtils.Round(convertmin * 10, 0);
}
else {
if (parseFloat(convertmin) < 10) {
return hrs + "." + ERPScriptUtils.Round(convertmin, 2) * 10;
}
else {
return hrs + "." + ERPScriptUtils.Round(convertmin, 2);
}
}
}
else {
return hrs + ".00";
}
},
///<summary>Method to round decimal no. to given no. of positions</summary>
/// <param name="x" >
/// Input decimal value
/// </param>
///<param name="y" >
/// No. of decimal points to be restricted
/// </param>
return Math.round(x * Math.pow(10, y)) / Math.pow(10, y);
//return parseFloat(x).toFixed(y);
},
RoundTime: function (x, y) {
///<summary>Method to round decimal no. to given no. of positions</summary>
/// <param name="x" >
/// Input decimal value
/// </param>
///<param name="y" >
/// No. of decimal points to be restricted
/// </param>
var time = x;
var timeArr = String(time).split('.');
var hrs = timeArr[0];
var min = 0;
if (parseFloat(timeArr[1]) > 0) {
min = 60 * parseFloat(timeArr[1]);
}
//var minArr = String(min).split('.');
var convertmin = parseFloat(min) / 10000000000000000;
if (parseFloat(convertmin) > 0) {
if (parseFloat(convertmin) < 1) {
return hrs + ".0" + ERPScriptUtils.Round(convertmin * 10, 0);
}
else {
if (parseFloat(convertmin) < 10) {
return hrs + "." + ERPScriptUtils.Round(convertmin, 2) * 10;
}
else {
return hrs + "." + ERPScriptUtils.Round(convertmin, 2);
}
}
}
else {
return hrs + ".00";
}
},
No comments:
Post a Comment