Here is a simple example demonstrate that why the signed/unsigned is very important for time_t: one function records a timestamp: time_t t1 = time(NULL);
another function records a second timestamp: time_t t2 = time(NULL); and check which one is early by: if (t2 - t1 < 0) { printf("t2 is early than t1\n"); } But If time_t is an unsigned integer, the comparison can never become true: https://devblogs.microsoft.com/oldnewthing/20140122-00/?p=2013 Since most POSIX OS map time_t to a signed type, the above code(appears in many code bases) works very well until they meet NuttX. Actually, we hit the problem before which takes our engineer to debug this problem and find the root cause by several days. That's why I prefer to follow other OS practice if the spec is ambiguous like time_t. If 32bit signed time_t is unacceptable due to the 2038 problem, at least 64bit time_t should change to the signed integer. Otherwise, you will take time to debug the above problem soon or later. On Tue, Nov 5, 2024 at 6:05 PM Simon Filgis <si...@ingenieurbuero-filgis.de> wrote: > Thanks. So there are use cases for negative numbers of time. Interesting. > > > -- > Hard- and Softwaredevelopment Consultant > > Geschäftsführung: Simon Filgis > USt-IdNr.: DE305343278 > ISO9001:2015 <https://activities.ingenieurbuero-filgis.de/certifications> > > > On Tue, Nov 5, 2024 at 11:03 AM <michal.lyszc...@bofc.pl> wrote: > > > On 2024-11-05 08:13:19, Simon Filgis wrote: > > > Seems like a dump question, but why time needs to be signed? > > It doesn't. But you may want to go backwards to show date before 1970. > > This is > > usually implemented by using negative time. > > > > -- > > > > > .-----------------.-------------------.----------------------.-----------------. > > | Michal Lyszczek | Embedded C, Linux | Company Address | .-. > > opensource | > > | +48 727 564 419 | Software Engineer | Akacjowa 10a; 55-330 | oo| > > supporter | > > | https://bofc.pl `----.--------------: Brzezinka Sredzka PL | /`'\ > > & | > > | GPG FF1EBFE7E3A974B1 | Bits of Code | NIP: 813 349 58 78 |(\_;/) > > programer | > > > > > `----------------------^--------------^----------------------^-----------------' > > >