• I have a clock that I have been creating and I thought that I would add to support local date formats and time.
    But I could not figure out how to best support 12 and 24 hour time. Any one that know how best to do it?

  • Some clocks do it like that

    var _12hour = (require("Storage").readJSON("setting.jsĀ­on",1)||{})["12hour"]||false;
    

    It reads the 12hour value from the main settings file. If the settings file can not be read it initalizes the value with false.

    You can then test in your code if you need to draw a 12 hour or 24 hour value:

    if (_12hour){
    //do 12 hour stuff
    } else {
    //do 24 hour stuff
    }
    
  • Thanks, this is a good start.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How do I do to support 12 and 24 hour time in a digital clock?

Posted by Avatar for Fredrik @Fredrik

Actions