[Ovmsdev] Time units and functions
Michael Balzer
dexter at expeedo.de
Sat Oct 21 14:39:33 HKT 2023
Michael,
Am 20.10.23 um 07:02 schrieb Michael Geddes:
> Hi all,
>
> firstly, it seems we are using a bunch of time functions that are not
> thread-safe (localtime gmtime and asctime) (See recommendation here:
> https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html)
> - so I'll push up a p/r for that.
I don't see which recommendation you refer to on that page, but you're
right, we shouldn't use these unsafe calls. The correct way to avoid
concurrency issues is to use the "_r" versions of these, i.e.
"localtime_r" etc. -- these are included in newlib.
> Next is the couple of Metrics that are using the unit 'Seconds' but
> which are really time_t values..
> I'm looking to add a new Group of metrics for time with units
> UnixEpoch, UTCDate & LocalDate.
> This is what I have at the moment with the default metrics for
> m.time.utc as UTCDate and v.p.gpstime as LocalDate. (I can make them
> the same)
>
> m.time.utc 2023-10-19 11:22:28 UTC
> v.p.gpstime 2023-10-19 19:22:26 AWST
>
> Currently I've changed these in the JSON to be exported as
> "%FT%T.000Z" which is a semi standard for JSON.
>
> The 'conversion' for the date values doesn't do anything - these
> really only effect the output.
>
> I've also been looking at v.g.timerstart which is UTCTime & LocalTime
> units. I've fixed up conversions both way..
> v.g.timerstart 18:00:00local
>
> Thoughts on these? Cautions?
As long as the current uses won't be affected (shouldn't, as they use
AsInt()), I think that will be fine.
Btw, v.c.timerstart is the pendant for the charge timer.
Regards,
Michael
--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20231021/21e1e27e/attachment.sig>
More information about the OvmsDev
mailing list