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() + (hours > 11 ? ' PM' : ' AM');
59 return dateObj.toTimeString().substring(0, 5);
62 * Seconds to hours converter
67 secondsToHours: function Helpers_secondsToHours(seconds) {
69 str = ((seconds % 60 < 10) ? '0' : '') + (seconds % 60);
70 seconds = parseInt(seconds / 60, 10);
72 str = ((seconds % 60 < 10) ? '0' : '') + (seconds % 60) + str;
73 seconds = parseInt(seconds / 60, 10);
75 str = ((seconds % 24 < 10) ? '0' : '') + (seconds % 24) + str;
76 seconds = parseInt(seconds / 24, 10);
81 * Returns scroll position of the given scroll view.
82 * @param {object} element ScrollView element
83 * @returns {number} scroll position
85 getScrollPosition: function Helpers_getScrollPosition(element) {
86 return element.scrollview('getScrollPosition').y;
90 * Scrolls given jQuery ScrollView to given Y position.
91 * @param {object} element ScrollView element to be scrolled.
92 * @param {number} position Y position to scroll to
94 scrollTo: function Helpers_scrollTo(element, position) {
95 // don't allow scrolling too much
96 var maxPosition = element.children().first().outerHeight(true) - element.height();
97 if (maxPosition < 0) {
100 if (position > maxPosition) {
101 position = maxPosition;
107 element.scrollview('scrollTo', 0, -position);