Feature request : Determine the date formatting

There is a way to find out what the watches distance measurement should be in, i.e. KM or MILES.

But can we also have a way to determine whether the user wants the date in MM/DD/YY or DD/MM/YY format?

We need a way to make a call to find out the device config for this setting so we can display accordingly.

Thanks in advance.

The thing to remember is MM/DD/YY is US format but we in Europe large parts of the rest of the world use DD/MM/YY so this affects customers worldwide!
  • I asked about this previously. Honestly, I'd like to see something like strftime() with the %c, %D, %T format specifiers (at the very least). If you are willing to make an assumption about users based on their language, you could use the resource system to solve this problem. You would need several resource entries to do it right...

    This would be the default date format...

    <!-- resources\strings.xml -->
    <resources>
    <string id="ShortDateFormat_Day">%02d</string>
    <string id="ShortDateFormat_Month">%02d</string>
    <string id="ShortDateFormat_Year">%d</string>

    <string id="ShortDateFormat">$1$-$2$-$3$</string>
    </resources>


    And this would be the date format for the US.

    <!-- resources-eng_USA\strings.xml -->
    <resources>
    <string id="ShortDateFormat_Day">%02d</string>
    <string id="ShortDateFormat_Month">%d</string>
    <string id="ShortDateFormat_Year">%d</string>

    <string id="ShortDateFormat">$2$/$3$/$1$</string>
    </resources>


    Here is the code to render that data into something useful.

    var date = Calendar.info(moment, Time.FORMAT_SHORT);

    // get the format for each of the components (may be zero padded or not)
    var y = Ui.loadResource(Rez.Strings.ShortDateFormat_Year);
    var m = Ui.loadResource(Rez.Strings.ShortDateFormat_Month);
    var d = Ui.loadResource(Rez.Strings.ShortDateFormat_Day);

    // get the ordering of the date components
    var format = Ui.loadResource(Rez.Strings.ShortDateFormat);
    var formatted = Lang.format(format, [ date.year.format(y), date.month.format(m), date.day.format(d) ]);


    For today's date, you'd see 1/13/2015 when using the eng_USA resource, and 2015-01-13 using fre_FRA or any other locale.
  • Great idea and suggestion there Travis
  • But how can I detect US English which uses MM/DD and British English which uses DD/MM

    According to the devices.xml the languages supported are :

    <language>hrv</language>
    <language>ces</language>
    <language>chs</language>
    <language>cht</language>
    <language>dan</language>
    <language>dut</language>
    <language>eng</language>
    <language>fin</language>
    <language>fre</language>
    <language>deu</language>
    <language>gre</language>
    <language>hun</language>
    <language>ita</language>
    <language>jpa</language>
    <language>nob</language>
    <language>pol</language>
    <language>por</language>
    <language>rus</language>
    <language>slo</language>
    <language>slv</language>
    <language>spa</language>
    <language>swe</language>

    Only one English! HELP!
  • Read the Monkey C Programmer's Guide. When defining your resources, you can specify the country code. I did this in my example above.

    I'm not exactly sure how to specify the country when using the simulator, or how the device would properly determine this, but it isn't a detail I'm concerned with. If the folks at Garmin claim it works, and I use it in my app only to find out it doesn't work... A) it is no worse than if I hadn't done anything at all, and B) I would complain to Garmin that the functionality they offer doesn't work.
  • OK I will give it a try but it would be great if someone at Garmin could explain how this could work for British English and US English. Yes I can add something in the resources file but does the watch detect the country you're in!?!?! That would be bad cos if you were US but in UK then the date formatting would be incorrect. It should show based on the users decision NOT where you are on the planet!

    And this is what this thread is about - it's about a realistic and reliable way to set the date formatting correctly for users across the globe!

    So please garmin please let me know, please. Pretty please.
  • Yes I can add something in the resources file but does the watch detect the country you're in!?!?!


    They provide a resource system that takes the country code into account. If you created the resource as described in the documentation and it didn't, then you should file an issue with the Garmin developers? As far as I can tell, there is no way to set the country in the simulator or on the device. That doesn't mean that they'll do it wrong or that it won't work, it just means that the particular feature isn't fully implemented yet.

    I'd be happy if they'd chime in as well, but until they do, I will wait patiently and annoy you. :)

    Also, here is a link to the post where I previously asked for the localized information you're looking for.
  • How does it take into account the country? If you cannot set it in the device or in the simulator then it must do it based on location i.e. via GPS. That is terrible as it means, like I said it will show the incorrect format for US citizens in the UK and UK citizens in the US.

    PLEASE GARMIN CAN YOU ANSWER!?

    And Travis, feel free to annoy me but please feel free to annoy but be careful that your answers don't cloud the issue I have so garmin miss my questions. Thanks! :-)
  • PLEASE GARMIN CAN YOU ANSWER!?

    Yes, we can! Please have patience with us, as we're not monitoring the forums 24/7. We're also working hard on the next SDK release.

    How does it take into account the country?

    Travis is correct that you could use the resource system to differentiate between most date formats. As you pointed out though in the simulator there isn't a way to choose English-US or English-UK. If you have a 920 available, you'll notice that this option doesn't exist on the watch either, so the string resources won't work in this case. Your best bet will be to use the upcoming settings system. For now you'll have to pick one way to display the date, until the settings system is released. I suggest using ISO 8601 for now :D. Sorry for any inconvenience this has caused.
  • Thank you for replying, it's appreciated. I shall wait for the upcoming settings system. Bring it on!
  • I'm wondering if there are any updates on this issue.  I'm new to connect IQ, and everything I've seen about date formats is about 5+ years old.  Are all app developers (that is all those who don't force a single date format on all their users) currently creating their own date format setting or is there a better solution now?