board/native: set TZ to UTC by default#20023
Conversation
|
setting the enviroment is actually the suggested portable solution by gnu libc |
|
I assume this will also affect the time returned by Then this will cause confusion because the time 'inside' native does no longer line up with the system time. |
| */ | ||
| void board_init(void) | ||
| { | ||
| setenv("TZ", "UTC", 0); |
There was a problem hiding this comment.
Let's guard this behind a pseudo-module or config option that gets selected by Makefile.tests_common
There was a problem hiding this comment.
how did you set the rtc ? (we should probably start it at 0 where most of our boards start) :)
There was a problem hiding this comment.
I did not set it at all, it's synced with the system time by default.
There was a problem hiding this comment.
I like sane defaults and the time functions are insane and even more so if timezone things are happening lets ditch then in a more sane direction by default.
if you like your localtime to much TZ=/etc/localtime <elf_file> or TZ=/etc/localtime make term or test
is an option
using mktime on native is a gamble otherwise maybe we should run a Linter that warns and errors about that.
There was a problem hiding this comment.
IMHO native showing the same time as the host system is a sane default.
Why not make it a config option so we can have predictive behavior for tests that need it without forcing everyone to accept UTC as the one true time?
There was a problem hiding this comment.
- cause in networking our timestamps are usually UNIX time - which is kind of UTC.
- since RIOT is an IoT OS we should probably be as compatible as we can.
2423137 to
842a74e
Compare
|
Maybe we could have the Not being slightly off but a lot off may look more intentional to a user and is more consistent to the behavior of real hardware. Having the timezone of the host not leak into the |
|
What's the status on this one? Mind looking into it before the upcoming release? |
|
rebased to resolve merge confict |
|
I blocked that because back then I was doing a lot of tests with I'm not doing that now, so if you really think running |
because it effects the application that use mktime and co and is not isolated to tests |
boards/common/native/doc.md
Outdated
| - execute `export TZ=":/etc/localtime"` prior `make term` in the very shell you intend to run make term in | ||
| - add `export TZ=":/etc/localtime"` to your `~/.profile` | ||
| - run `TZ=":/etc/localtime" make term` | ||
| - set `TZ` in riot application picolibc and newlib are able to respect that setting if `+/-hh:mm:ss` |
There was a problem hiding this comment.
Can't we just add this to pyterm so it's less user hostile?
There was a problem hiding this comment.
i will not: i think doing things wrong (make embedded things that assume no timezone behave wrong) should not be the default.
i think mktime behaving different on native and on embedded is much more user hostile
if one wants mktime behave like it is in a timezone there are easy ways in application or environment
and i put them in the documentation
ae55ecc to
933a498
Compare
boards/common/native/doc.md
Outdated
| - RTC: host-time but at 'UTC' to behave consistent with embedded systems if TZ is set that timezone will be used. | ||
| - set `TZ` environment variable e.g.: | ||
| - execute `export TZ=":/etc/localtime"` prior `make term` in the very shell you intend to run make term in | ||
| - add `export TZ=":/etc/localtime"` to your `~/.profile` | ||
| - run `TZ=":/etc/localtime" make term` | ||
| - to set set `TZ` in riot application as picolibc and newlib are able to respect that setting if `NAME+/-hh:mm:ss` | ||
| (-time is added, +time is subtracted from UTC (+ pointing WEST England towards America) see `man timezone` | ||
| eg.: `IST-5:30` or `TZ="NZST-12NZDT-13,M10.1.0,M3.3.0"` or `TZ="CET-1CEST-2,M3.5.0,M10.5.0"` or `TZ="ACST-9:30ACDT-10:30,M10.1.0,M4.1.0"` |
There was a problem hiding this comment.
Thanks for the detailed documentation! It's a lot though now, and I'd say it warrants a separate subsection.
55466d4 to
f73e6cc
Compare
mguetschow
left a comment
There was a problem hiding this comment.
Thanks for the documentation, some formulation suggestions below.
mguetschow
left a comment
There was a problem hiding this comment.
One last round, then I'd be satisfied :)
c1ffdbb to
8f8c136
Compare
Contribution description
board/native: set env TZ to UTC by default
also fix the failing minema test - that assumend to be run in Berlin/Paris/Hamburg/Rom/Wien
most (all) embedded libc do not care for TZ and time functions don't do timezone conversion,
making native use UTC for time.h functions does the same
you can still force localtime timezone
TZ=":/etc/localtime" <elf_file>orTZ=":/etc/localtime" make term or testorexport TZ=":/etc/localtime"oror another timezone
export TZ="LEET+1:33:7"(timezone name and offset from UTC optional DSTTesting procedure
run the minema test in Berlin and see that the time stamp is now UTC
Issues/PRs references
#20018 #20005