11 (function () { // strict mode wrapper
16 * Returns date in format YYYY/MM/DD
18 * @returns {String} formatted
20 getShortDate: function Helpers_getShortDate(dateObj) {
24 yyyy = dateObj.getFullYear().toString();
25 mm = (dateObj.getMonth() + 1).toString(); // getMonth() is zero-based
26 dd = dateObj.getDate().toString();
28 console.error('error', e);
31 return yyyy + '/' + (mm[1] ? mm : '0' + mm[0]) + '/' + (dd[1] ? dd : '0' + dd[0]);
34 * Returns date in format DD short_month YYYY
36 * @returns {String} formatted
38 toNativeDate: function Helpers_toNativeDate(dateObj) {
39 var date = dateObj.toDateString().split(" ");
41 return date[2] + ' ' + date[1] + ' ' + date[3];
44 * Returns time in format HH:mm or hh:mm ap
46 * @returns {String} formatted
48 toNativeTime: function Helpers_toNativeDate(dateObj) {
51 if (tizen.time.getTimeFormat().indexOf('ap') != -1) {
52 hours = dateObj.getHours();
53 apHours = hours % 12 < 10 ? '0' + hours % 12 : hours % 12;
55 return apHours.toString().replace("00", "12") + ':' +
56 (dateObj.getMinutes() < 10 ? "0" + dateObj.getMinutes() :
57 dateObj.getMinutes()) + (hours > 11 ? ' PM' : ' AM');
60 return dateObj.toTimeString().substring(0, 5);
63 * Seconds to hours converter
68 secondsToHours: function Helpers_secondsToHours(seconds) {
70 str = ((seconds % 60 < 10) ? '0' : '') + (seconds % 60);
71 seconds = parseInt(seconds / 60, 10);
73 str = ((seconds % 60 < 10) ? '0' : '') + (seconds % 60) + str;
74 seconds = parseInt(seconds / 60, 10);
76 str = ((seconds % 24 < 10) ? '0' : '') + (seconds % 24) + str;
77 seconds = parseInt(seconds / 24, 10);
82 * Returns scroll position of the given scroll view.
83 * @param {object} element ScrollView element
84 * @returns {number} scroll position
86 getScrollPosition: function Helpers_getScrollPosition(element) {
87 return element.scrollview('getScrollPosition').y;
91 * Scrolls given jQuery ScrollView to given Y position.
92 * @param {object} element ScrollView element to be scrolled.
93 * @param {number} position Y position to scroll to
95 scrollTo: function Helpers_scrollTo(element, position) {
96 // don't allow scrolling too much
97 var maxPosition = element.children().first().outerHeight(true) - element.height();
98 if (maxPosition < 0) {
101 if (position > maxPosition) {
102 position = maxPosition;
108 element.scrollview('scrollTo', 0, -position);