Hi all,
I would like to use the time library to manage multiple times with different timezones in my embedded system.
I would like reproduce the IAR method: (www.iar.com/.../)
But with Keil MDK-ARM, I don't find the solution to manage the different timezones or switch the current rule of the timezone. I don't find any API. I don't if it's necessary to write weak functions...
Can you help me?
In advance, thank you.
So why does it need to manage time zones & DST at all?
Simply send it the current offset, and re-send whenever it changes.
Simples!
Finally, I agree with you, thank you !
You're welcome!
You'd probably want to have some way to specify when the change should be applied ...
That is such a crude method, but since the OP's happy I'll not rock the boat.
You can suggest your complete solution if you want.
I would prefer to say, "simple".
I basically did before.
The units are loaded with locale information so the local time is generated from UTC. Daylight saving changes occurs by way of simple pre-determined rules and without user interaction.
The advantage of doing this is that any daylight saving changeover occurs automatically AT THE PRECISE TIME OF THE CHANGEOVER without having to rely on someone coming along sometime prior or sometime after the changeover. Having to rely on someone to manually issue a different offset at or around the changeover time is just horribly crude!
I've not looked into the detail of library functions for this automatic changeover. We chose to implement our own routines back in 2001 and they continue to operate nicely with no foreseen issues expected. These changeover determination operations and application of offset are not complex.
As it would in my suggested approach.
My approach just avoids having all that logic in the embedded system.
I was not suggesting that it be done manually!
OP indicated that a comms link is available - my suggestion was to use that, so that the logic does not need to be in the embedded system.
All that logic??? You one of those developers who considers code is better when it's got lots of lines??? It doesn't require much code and having it there would ensure that changeover occurs even if there were no communication link at the particular time.
But hey, let's just let the OP choose whether they want crude or reliable.
Obviously not - as my whole point is to reduce the amount of stuff in the embedded device!
"Simpler" usually has a better chance of being "reliable".
In this situation, you might end up being at the mercy of communications and the reliability of that at a critical time. So your simpler could easily end up with unacceptable failure and therefore possibly not considered reliable.
Pre 2001, before we included this little code into our embedded devices we understandably got complaints when time changeover either didn't occur or occurred late. Not good Pesky TCP and RS-485 always chose the best times to hiccup. So we always now go for the RELIABLE and ACCEPTABLE OVERHEAD approach. Written once, ported with no trouble to various platforms and lasted 17 years (so far).