-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathformatter.js
More file actions
31 lines (31 loc) · 951 Bytes
/
formatter.js
File metadata and controls
31 lines (31 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sap.ui.define(["sap/ui/core/format/DateFormat"], function(DateFormat) {
"use strict";
return {
removeLeadingZerosFromString: function(numberString) {
return parseInt(numberString, 10);
},
numberOfDaysBetweenTwoDates: function(date) {
var today = new Date();
var finishDate = new Date(date);
var difference = Math.round((finishDate - today) / (1000 * 60 * 60 * 24));
var value = (difference < 0) ? "(" + (difference * -1) + ")" : difference;
return value;
},
dateFormat: function(date) {
var oDateFormat = DateFormat.getDateInstance({
pattern: "MM/dd/yyyy"
});
return oDateFormat.format(new Date(date));
},
integerWithThousandsSeparator: function(number){
//2509 will be shown as 2,509
var oIntegerInstance = NumberFormat.getIntegerInstance({
style: "standard",
groupingEnabled: true
});
var formattedNumber = oIntegerInstance.format(number);
return formattedNumber;
}
}
}
]);