stefanu
stefanu

Reputation: 357

Garmin ConnectIQ SDK date format

While developing a watch face for the Garmin Fenix 3, I came across the need to display the date using either MM/DD or DD/MM formats.

The API does not allow settings to be saved for custom watch faces, so the only way to do this is by using some system property... which I am unable to find in the API docs.

On the other hand, once connected to an iPhone, one can access watch settings, and among those, there is the date format setting, so there must be something.

Any help or hints on how to handle this are appreciated. Thanks in advance.

Upvotes: 1

Views: 1250

Answers (2)

Travis Vitek
Travis Vitek

Reputation: 226

The settings functionality provided by the SDK can be used to allow the user to specify what format to use. There are examples of how to use application settings in the programmer's guide.

Upvotes: 0

Perttu Haliseva
Perttu Haliseva

Reputation: 977

True, API is missing a way to check user's preference for date format. Garmin's own watchfaces seem to work around this by omitting month altogether and only showing "MON 12".

I would take a look at user's time settings. If she uses 24H clock, I'd say it's quite safe to assume she would like to see DD/MM format. Or, to take it a step further, maybe assign a "score" deducted from several settings:

function getMonthFormat () {
    var score = 0;
    var settings = System.getDeviceSettings();

    if(settings.distanceUnits == System.UNIT_METRIC) score++;
    if(settings.paceUnits == System.UNIT_METRIC) score++;
    if(settings.temperatureUnits == System.UNIT_METRIC) score++;
    if(settings.weightUnits == System.UNIT_METRIC) score++;

    // 2/4 should be a safe assumption
    if(score >= 2) {
        return "ddmm";  // or whatever
    } else {
        return "mmdd";
    }
}

Upvotes: 3

Related Questions