24H Settings

Former Member
Former Member
Hi,
I believe that it was possible to override in the settings, or in the ressource file the settings to have allways the 24H setting, but I don't find where I have see that.
Was it a dream, or is it really possible , and how ?
  • I'm having a hard time determining what you are asking about or trying to do. Could you try to clarify?
  • Former Member
    Former Member over 8 years ago
    Sorry,
    in fact, your watch is parametered on 12 hours (with am and pm), or in 24 hours,

    For example : 13:35 is 01:35 in 12 mode.

    I wanted to force the setup in the 24 mode if possible. I made calculations only in 24 for the moment, and I wanted to avoid surprises in 12 mode.

    Thanks,
  • I'm still not confident that I understand your question... If you want a watch face that you've developed to always use 24-hour mode, then don't write any code to support 12-hour mode. You don't need any fancy resource tricks or settings, just don't write any code that depends on the Sys.getDeviceSettings().is24Hour flag.

    Travis
  • Sorry,
    in fact, your watch is parametered on 12 hours (with am and pm), or in 24 hours,

    For example : 13:35 is 01:35 in 12 mode.

    I wanted to force the setup in the 24 mode if possible. I made calculations only in 24 for the moment, and I wanted to avoid surprises in 12 mode.

    Thanks,



    Hi,
    there shouldn't be any surprise for you.
    If you get the time like this,
    ...
    var clockTime = Sys.getClockTime();
    var hours = clockTime.hour;
    ...

    you will get the time in 24h format.

    If you want to support am/pm you explicitly have to program it... something like
    if (!Sys.getDeviceSettings().is24Hour) {
    if (hours > 12) {
    hours = hours - 12;
    }
    ....

    And to be 100% sure you can also test the 12/24h mode on the simulator.
  • If you're doing calculations based on time, the time you get from the FW is always in 24 hode. Only for display do you need to check the setting for is24Hour and convert the hours as needed

    (btw, in the above post you also want to have something like:

    hours=(hours==0)?12:hours;

    As there is no "0" hours in 12 hour mode.)

    If you are doing math on different times, there are other ways to do it than using hrs/mins/secs. As an old c and unix guy, I always do it in seconds.

    var start=Time.now().value();

    gives you the "unix time" in seconds (the number of seconds since Jan1 1970)

    Lets say you want to compare the current time to start. Then you use:

    var now=Time.now().value();
    var elapsed=now-start;

    elapsed is the number of seconds between now and when you started. It's then a simple conversion to display it as hh:mm:ss. It will also handle difference is days, weeks, months, even years.
  • Former Member
    Former Member over 8 years ago
    What is the start ? Because this is the same as the now in your code.

    Anyway, I normally make the conversions, but I have seen some strange behaviours when in 12 mode in simulator ( 08h75 for example).
    I'll have a closer look on it. I wanted the easy way (baad ;)) that was to avoid it.

    Rgds
  • Former Member
    Former Member over 8 years ago
    If you are doing math on different times, there are other ways to do it than using hrs/mins/secs. As an old c and unix guy, I always do it in seconds.

    var start=Time.now().value();

    gives you the "unix time" in seconds (the number of seconds since Jan1 1970)

    Lets say you want to compare the current time to start. Then you use:

    var now=Time.now().value();
    var elapsed=now-start;

    elapsed is the number of seconds between now and when you started. It's then a simple conversion to display it as hh:mm:ss. It will also handle difference is days, weeks, months, even years.



    Hi Jim,
    I'm trying to make those kind of calculations.

    but I Wonder how to create a custom start ; as you put your 'start' as now.

    If I wants to have the start : today -18:00:00

    how to create the start time in secs. I guess that Moment class is involved, but I don't find any constructor for it.

    Thanks,