Results 1 to 3 of 3

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Change 24-hour clock to 12-hour [Custom lockscreen]

  1. #1
    Default Change 24-hour clock to 12-hour [Custom lockscreen]
    Can anyone show me how to change this 24-hour clock to a 12-hour clock?

    Code:
    /* dont change anything below this line unless you know what you are doing :-) */
    
    
    
    var d = new Date();
    
    var hours = d.getHours();
    
    var minutes = d.getMinutes();
    
    var seconds = d.getSeconds();
    
    
    
    var acc_x, acc_y;
    
    var deg = 0;
    
    var deg_new = 0;
    
    var deg_set = 0;
    
    var deg_time = 0;
    
    var state = 'default';
    
    
    
    
    
    function initiate() {
    
            
    
            if (hours > 12) hours360 = hours - 12;
    
            else hours360 = hours; 
    
            
    
            minutesDeg = 6 * minutes;
    
            hoursDeg   = 30 * hours360;
    
            secondsDeg = 6 * (seconds + 2);
    
            
    
            if (hours < 10) hours = '0' + hours;
    
            if (minutes < 10) minutes = '0' + minutes;
    
            
    
            
    
            //circles
    
            document.getElementById("minutes-c").childNodes[1].style.webkitTransform = 'rotate(' + minutesDeg + 'deg)';
    
            document.getElementById("hours-c").childNodes[1].style.webkitTransform = 'rotate(' + hoursDeg + 'deg)';
    
            document.getElementById("seconds-c").childNodes[1].style.webkitTransform = 'rotate(' + secondsDeg + 'deg)';     
    
            
    
    
    
            //center
    
            document.getElementById("am_pm").innerHTML = hours + ':' + minutes;
    
            document.getElementById("day").innerHTML = Day();
    
            
    
            date = d.getDate();
    
            month = d.getMonth() + 1;
    
            year = new String(d.getFullYear());
    
            
    
            if (date < 10) date = '0' + date; 
    
            if (month < 10) month = '0' + month; 
    
            year = year.substr(2, 2);
    
            
    
            document.getElementById("date").innerHTML = month + ' | ' + date + ' | ' + year;    
    
            
    
            setTimeout(no_animation_delay, 2200); // removes animation delay and lowers current clock animations from 2 seconds to 1
    
    }
    
    
    
    function no_animation_delay() {
    
            document.getElementById("main-wrapper").style.webkitTransitionDelay = '0s';
    
            document.getElementById("main-wrapper").style.webkitTransition = 'all 1s ease-in-out';
    
            
    
            //console.log(document.getElementById("circles").getElementsByTagName("img").style);
    
            
    
            var circles = document.getElementById("circles").getElementsByTagName('img');
    
            for (var i = 0; i < circles.length; i++) {
    
                    circles[i].style.webkitTransitionDelay = '0s';
    
                    circles[i].style.webkitTransition = 'all 1s ease-in-out';
    
            }
    
            
    
            document.getElementById("seconds-c").childNodes[1].style.webkitTransition = 'all 0.3s linear';
    
            
    
            setTimeout(update, 500); // starts normal clock updating process
    
    }
    
    
    
    function update() {     
    
            d = new Date();
    
            hours = d.getHours();
    
            minutes = d.getMinutes();
    
            seconds = d.getSeconds();       
    
    
    
            if (hours > 12) hours360 = hours - 12;
    
            else hours360 = hours;  
    
            
    
            minutesDeg = 6 * minutes;
    
            hoursDeg   = 30 * hours360;
    
            secondsDeg = 6 * seconds;       
    
    
    
            if (hours < 10) hours = '0' + hours;
    
            if (minutes < 10) minutes = '0' + minutes;
    
            
    
            //circles
    
            document.getElementById("minutes-c").childNodes[1].style.webkitTransform = 'rotate(' + minutesDeg + 'deg)';
    
            document.getElementById("hours-c").childNodes[1].style.webkitTransform = 'rotate(' + hoursDeg + 'deg)';
    
            
    
            if (seconds == 0) {
    
                    document.getElementById("seconds-c").childNodes[1].style.webkitTransition = 'all 1s ease-in-out';
    
            } else if (seconds == 1) {
    
                    document.getElementById("seconds-c").childNodes[1].style.webkitTransition = 'all 0.3s linear';
    
            }
    
            
    
            document.getElementById("seconds-c").childNodes[1].style.webkitTransform = 'rotate(' + secondsDeg + 'deg)';     
    
            
    
            //center
    
            document.getElementById("am_pm").innerHTML = hours + ':' + minutes;
    
            document.getElementById("day").innerHTML = Day();
    
            
    
            date = d.getDate();
    
            month = d.getMonth() + 1;
    
            year = new String(d.getFullYear());
    
            
    
            if (date < 10) date = '0' + date; 
    
            if (month < 10) month = '0' + month; 
    
            year = year.substr(2, 2);
    
            
    
            document.getElementById("date").innerHTML = month + ' | ' + date + ' | ' + year;    
    
    
    
            //tilt
    
            document.getElementById("main-wrapper").style.webkitTransform = 'rotate(' + rotate() + 'deg)';  
    
            //tilt
    
            
    
            
    
            setTimeout(update, 1000);
    
    }       
    
    
    
    function Day () {
    
        day = new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");
    
        return day[d.getDay()];
    
    }
    
    
    
    
    
    function rotate (accelerationx, accelerationy) {
    
            deg_time++;
    
            // all the numbers down below represent the sensitivity used for rotation triggers
    
            if (acc_y < 3 && acc_x > -7 && acc_x < 7) {
    
                    //normal
    
                    deg_new = 0;
    
                    state = 'normal';
    
            } else if (acc_x < -6) {
    
                    //left
    
                    deg_new = 90;
    
                    state = 'left';
    
            } else if (acc_x > 6) {
    
                    //right
    
                    deg_new = -90;
    
                    state = 'right';
    
            } else if (acc_y > 4) {
    
                    //upside
    
                    deg_new = -180;
    
                    state = 'upside';
    
            }
    
            
    
            if (deg != deg_new) {
    
                    difference = deg_time - deg_set;
    
                    
    
                    if (difference >= 2 || deg_set == 0) {
    
                            deg_set = deg_time;
    
                            deg = deg_new;
    
                    } else {
    
                            //animation postponed
    
                    }
    
            }
    
            
    
            //if decision wasnt made, default or previous deg value will be returned
    
            //console.log(acc_y + ' ' + acc_x + ' ' + state); // used for debugging 
    
            return deg;
    
    }
    
    
    
    
    
    // orientation begin
    
    
    
    
    
    if (window.DeviceMotionEvent) {
    
            window.addEventListener('devicemotion', deviceMotionHandler, false);
    
    }
    
    
    
    function deviceMotionHandler(eventData) {
    
            var acceleration = eventData.accelerationIncludingGravity;
    
    
    
            acc_x = acceleration.x;
    
            acc_y = acceleration.y;
    
    }
    
    
    
    
    
    // orientation end

  2. #2
    What's Jailbreak?
    Join Date
    Jan 2014
    Location
    Ижевск, Russia
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    12 replace 24

  3. #3
    Will this coding change the clock in Rising Bars from its 24-hour clock to a 12-hour one?

    Thanks.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •