While using time.h to format date and time like: strftime(sttime, sizeof(sttime), "%d.%B ", &timeinfo);
i changed the language in DateStrings.cpp and deleted the original file.
Still i see the english text: %B still gives "March" although there is "maart" in DateStrings.cpp.
No other relevant files contain "March", so where does it come from? and why doesn't it show the translation?
In DateStrings.cpp can be read that it should be possible to change this:
* No memory is consumed in the sketch if your code does not call any of the string methods
* You can change the text of the strings, make sure the short strings are each exactly 3 characters
* the long strings can be any length up to the constant dt_MAX_STRING_LEN defined in TimeLib.h
I think strftime() only uses English on our Arduino. (the standard Arduino environment doesn't provide a built-in mechanism to change locales like in some other programming environments)
You would have to call DateStrings' API to get the changes you made.
Also if your modified copy is in your sketch directory, don't forget to include using double quotes and not the usual <....>
Thanks, i solved it by copy the "array's" from DateStrings.cpp to the program itself..and point to the right string with timeinfo.tm_wday or tminfo.tm_mon:
When you have understanding, the code is concise and clear. Whenever my 'gut' tells me that looks like too much code to do that, it usually is. THANK YOU for this great example of a common requirement. Few programmers fully understand the subtle issues with the date. I got 'schooled' when I had to synchronize three computers located on different continents. I struggled for a while but eventually did what had to be done and the code was clean.
This is how i did it... almost.
I noticed DateString.cpp is used while compiling ( i forgot a ; somewhere and got that error..)
Calling monthNames_P[xxx] gave the error that this was not in scope, So i copied it within my programm, changed the names and that worked.
I can give it a try to use monthStr(xx) and see if that gets the names from DateStrings.cpp..
Then i can remove that part from the program.
Do you really need to build the full String ? That’s using memory and time. If this is for display, consider just printing the string in multiple steps, one element at a time.
Does it realy matter that much? If i split it up in parts i have to enter the display-routine so many times. Instead of one call " showDate(); " i have to make 3 calls, ShowDOW(), ShowDate() and ShowMonth(), or something like that..
The news items are much longer and getting the 's out of the whole RSS-feed takes much more time, i guess. (sometimes i see it hold for a fraction of a second)
Ok, less program-memory is used: 102 byte... (1047047 - 1046872), mainly because i have to convert the first part to String else it won't compile.
The scrollText is filled with all kinds of text every time it is fully displayed (time, date, news, local important messages etc.)
Without any parentheses to change the order, the compiler is applying the + operator left-to-right, one pair of operands at a time. Using += is both more clear and in a slight way less clear.
Serial.print() is so much more forgiving than an array of characters. for instance UTF-8 has to be examened. Serial.print just shows the right character
One issue is what + is used as it is overloaded in the String class . In the following code
The first print takes a pointer to a c string as parameter and the + operator is the one for a char * pointer, hence moving the pointer one byte forward for each unit value in a and b
The latter print applies to the String type and thus is the overloaded concatenation operator and thus a and b are implicitly promoted to String in the hidden process (using transient memory for that).