<div dir="ltr"><div dir="ltr">Michael,</div><div>BTW I've since added AsString() implementation for both the LocalTime, UTCTime, and LocalDate and UTCDate.</div><div>The Date values need to be the format yyyy-mm-ddThh:nn:ss - ie 2023-02-20T13:01:00 I figured that would be the </div><div>easiest to avoid having a space in the value!</div><div><br></div><div>Also more inline below:</div><div><br></div><div>//.ichael</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 21 Oct 2023 at 14:39, Michael Balzer <<a href="mailto:dexter@expeedo.de">dexter@expeedo.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Michael,<br>
<br>
Am 20.10.23 um 07:02 schrieb Michael Geddes:<br>
> Hi all,<br>
><br>
> firstly, it seems we are using a bunch of time functions that are not <br>
> thread-safe (localtime gmtime and asctime) (See recommendation here: <br>
> <a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html" rel="noreferrer" target="_blank">https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html</a>) <br>
> - so I'll push up a p/r for that. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I don't see which recommendation you refer to on that page, but you're <br>
right, we shouldn't use these unsafe calls. The correct way to avoid <br>
concurrency issues is to use the "_r" versions of these, i.e. <br>
"localtime_r" etc. -- these are included in newlib.<br></blockquote><div><br></div><div>It's in the section 'Get Current Time' as a code snippet, however yes, I'm using the _r versions of the functions.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> Next is the couple of Metrics that are using the unit 'Seconds' but <br>
> which are really time_t values..<br>
> I'm looking to add a new Group of metrics for time with units <br>
> UnixEpoch, UTCDate & LocalDate.<br>
> This is what I have at the moment with the default metrics for <br>
> m.time.utc as UTCDate and v.p.gpstime as LocalDate. (I can make them <br>
> the same)<br>
><br>
> m.time.utc 2023-10-19 11:22:28 UTC<br>
> v.p.gpstime 2023-10-19 19:22:26 AWST<br>
><br>
> Currently I've changed these in the JSON to be exported as <br>
> "%FT%T.000Z" which is a semi standard for JSON.<br>
><br>
> The 'conversion' for the date values doesn't do anything - these <br>
> really only effect the output.<br>
><br>
> I've also been looking at v.g.timerstart which is UTCTime & LocalTime <br>
> units. I've fixed up conversions both way..<br>
> v.g.timerstart 18:00:00local<br>
><br>
> Thoughts on these? Cautions?<br>
<br>
As long as the current uses won't be affected (shouldn't, as they use <br>
AsInt()), I think that will be fine.<br></blockquote><div>Yeah, as for as the code goes they are still integers. At the moment the main change is that I have</div><div>m.time.utc default to UTCTime unit (rather than UnixEpoch) and v.p.gpstime default to LocalTime. This will</div><div>mean changes to the user interface and scripting interface for those values. I'm ok with leaving it like that or I could just</div><div>default to UnixEpoch.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Btw, v.c.timerstart is the pendant for the charge timer.<br></blockquote><div> </div><div>AH yeah, I worked that bit out. I initially though UTCTime was for a time_t value but I twigged to where that value was coming from </div><div>and what that meant. </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regards,<br>
Michael<br>
<br></blockquote><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-- <br>
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal<br>
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26<br>
<br>
_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.openvehicles.com" target="_blank">OvmsDev@lists.openvehicles.com</a><br>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" rel="noreferrer" target="_blank">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br>
</blockquote></div></div>