Inconsistency in locale.time output

Posted on
  • >require("locale").time(new Date());
    =" 4:00.04 pm"
    >require("locale").time(new Date(), 1);
    ="16:00"
    

    Hi all! I'm confused by the disparities between these two date formats. I'm expecting the long format to also be in 24h time. Has anyone else seen this?

  • Looks ok to me, at least for german local:

    require("locale").time(new Date());
    ="07:28:24"
    require("locale").time(new Date(), 1);
    ="07:28"

    What locale are you using?

  • I think it looks the same because you're before 1pm?

    It does depend on what locale you have and whether you have 12 hour set in your bangle.js settings (under Locale).

    But looking at the (default) code at https://github.com/espruino/Espruino/blo­b/master/libs/js/banglejs/locale.js#L11C­2-L12C36

    The logic seems to be:

    • 12 hour: Everything is 12 hour
    • 24 hour: 'short' time is 24 hour, but 'long' time is always 12 hour

    But then if you install a language-specific locale, you get: 16:00:04 or similar (just seconds, no meridian) in pretty much all cases: https://github.com/espruino/BangleApps/b­lob/master/apps/locale/locales.js#L74

    So I'd be tempted to change the default implementation for the Bangle to work the same way?

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

Inconsistency in locale.time output

Posted by Avatar for sleepypilled_zz @sleepypilled_zz

Actions