Commit Graph

32 Commits

Author SHA1 Message Date
Anhad Singh 2575639212 fix(tests/time): explictly set timezone instead of assuming 2025-12-09 01:18:32 +11:00
Josh Megnauth 4538fdb0c9 Implement timespec_get and timespec_getres
`timespec_get` and `timespec_getres` are both C23 functions. They're
similar to the POSIX functions `clock_gettime` and `clock_getres`, but
both sets of functions define extra, exclusive features. I didn't
implement the extra features yet, partially because Redox doesn't seem
to support them yet either.
2025-12-04 20:38:35 +00:00
Josh Megnauth 090391d94f fix(strptime): Don't clobber struct tm
Our strptime implementation uses subformatting to handle specifiers that
expand to other specifiers. For example, '%T' expands to "%H:%M%:%S".
Relibc calls strptime again to handle '%T' by expanding it.

However, our strptime zeroes out struct tm which clobbers old values. If
strptime is called with a format string like "%D%t%T", the set values
for '%D' are clobbered.

Zeroing out the struct is extra, unneeded work as well. The user may
want to preserve old values. We don't read from struct tm so we don't
have to worry about invalid values. Finally, `musl` and `glibc` don't
clear the values either so we can default to their behavior.
2025-04-01 23:35:29 -04:00
Darley Barreto 26573d02d1 Time improvements 2025-03-29 19:29:20 +00:00
Josh Megnauth e827b4f61f Add strptime tests 2025-03-29 14:01:29 +00:00
Josh Megnauth ccc1b7f560 strftime: ISO-8601 leap weeks 2025-03-20 02:34:26 -04:00
Darley Barreto dda7142385 Few improvements to time.h 2025-02-26 23:58:57 +00:00
Darley Barreto c14b2cee4c Adding tzset, timezone awareness, and some tweaks 2025-01-02 20:19:34 +00:00
4lDO2 5f929ed51e Enable -Wextra in tests. 2023-11-12 12:07:49 +01:00
Ron Williams 95e9162d22 change tzname to be mut 2023-05-06 13:20:30 -07:00
Ron Williams c3f3da6958 fix tzset cbindgen declarations 2023-05-06 02:55:36 -07:00
Peter Limkilde Svendsen e3a0fdbc4a Test for time.h constants 2021-02-23 18:35:24 +01:00
Peter Limkilde Svendsen 00642dd940 Test extreme tm member values 2020-09-17 23:10:13 +02:00
Peter Limkilde Svendsen ff6bc68260 Add more gmtime() tests 2020-09-08 18:44:55 +00:00
Peter Limkilde Svendsen b15c90ee32 Add test for ctime_r() 2020-05-26 00:20:14 +02:00
Jeremy Soller 2c3195d54b Ignore clock function in time/time 2019-07-06 19:09:24 -06:00
Tibor Nagy a92be000fb tests: Even more work on error handling
realpath: Fixing undefined behaviour in the second test. If the call fails the resolved_name argument cannot be used for error checking because its state is undefined by SUSv2.
pipe: Changing the order of close and write error handling code. Errors in close could overwrite errno after write errors, returning incorrect error messages.
gmtime: Removed duplicate checks
Other fixes for fseek, rename, mktime, putwchar
2019-02-24 22:02:11 +01:00
Tibor Nagy 9a0ea6ff34 tests: More refactoring, add helper header to every test, override exit for better error reporting 2019-02-21 21:13:28 +01:00
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
This will allow us to redefine the exit function.

For example:
```
#define exit(code) { \
    fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
        __FILE__, __LINE__, #code, __func__); \
    _exit(code); \
}
```
2019-02-21 12:15:06 +01:00
Tibor Nagy 4381bb2a22 tests: Remove redundant return statements
When the execution reaches the end of the main functions, they implicitly return a successful status.
2019-02-20 21:09:03 +01:00
Tibor Nagy c19cc8b731 tests: Portability fixes, replaced 0/1/-1 return codes with macros 2019-02-20 20:20:07 +01:00
Tibor Nagy ff874c87d7 tests: Fix function signatures 2019-02-20 19:27:18 +01:00
Tibor Nagy 7ee59d2fdb tests: set C11, enable pedantic warnings, fix GCC and Clang warnings 2019-02-20 15:04:47 +01:00
Jeremy Soller 950b4526c7 - Disable output of empty header files
- Remove incorrect header styles
- Use export.replace where header style was previously needed
- Check compilation of tests using system gcc
2018-11-26 21:35:02 -07:00
jD91mZM2 b517629371 Fix timeradd
wow i am stupid for writing this code
2018-10-11 19:52:54 +02:00
jD91mZM2 9d56ce42c6 Implement timer* macros, and GNU's getopt_long 2018-10-06 16:46:35 +02:00
jD91mZM2 eb6ddac1eb Unify gmtime and localtime code
Apparently gmtime was already implemented when I made localtime, so we had two different things written from scratch. We decided in the relibc channel of the Redox OS Mattermost chat to use my code, as it is more extensively tested and perhaps is clearer in how it works.
2018-09-05 15:52:25 +02:00
jD91mZM2 40a7380a58 Fix snprintf and make strftime use a counting writer 2018-08-07 21:31:05 +02:00
jD91mZM2 f82b48b839 Implement sys/times.h on linux 2018-07-29 09:23:56 +02:00
jD91mZM2 7ff6940edd Implement futimens 2018-07-26 13:26:54 +02:00
jD91mZM2 a0f2baff12 Implement gettimeofday 2018-07-26 10:07:33 +02:00
jD91mZM2 67d5976622 Clean up tests 2018-07-22 11:24:50 +02:00