Hi,
once again I found something not working :-)
private function setDateDisplay() {
var now = Time.now();
var date = Date.info(now, Time.FORMAT_LONG);
var heute = date.day_of_week();
if (heute == "Thu"){
var Wochentag = "Do";
}
var dateString = Lang.format("$1$, $2$ $3$, $4$", Wochentag, date.day, date.month, date.year]);
var dateDisplay = View.findDrawableById("DateDisplay");
dateDisplay.setText(dateString);
}
Now I wonder:
- why doesn't the if function work (I mean in the debugger I see that "heute" has the Value "Thu" and is a Lang.string
Second try:
Why doesn't the dictionairy work? I must admit that I'm not yet to familiar with them but should work according to
https://developer.garmin.com/connect-iq/api-docs/Toybox/Lang/Dictionary.html
private function setDateDisplay() {
var now = Time.now();
var date = Date.info(now, Time.FORMAT_LONG);
var heute = date.day_of_week();
var myDict = {
"Mon" => "Mo",
"Tue" => "Di",
"Wed" => "Mi",
"Thu" => "Do",
"Fri" => "Fr",
"Sat" => "Sa",
"Son" => "So"
};
var dateString = Lang.format("$1$, $2$ $3$, $4$", [myDict.get(heute), date.day, date.month, date.year]);
var dateDisplay = View.findDrawableById("DateDisplay");
dateDisplay.setText(dateString);
}
Can anybody give me the right solution for 1 and 2?
Mean theoretically they should both work !?!
Regards Marcus