Currently `DateTime::now()` on native uses POSIX `time(2)` — whole-second precision only.
Fix
Add a thin C stub calling `clock_gettime(CLOCK_REALTIME)` that returns nanoseconds as `Int64`. Replace the `time(2)` call in `now_native.mbt`.
```c
#include <time.h>
#include <stdint.h>
int64_t tempo_sys_unix_nanos(void) {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
}
```
Requires wiring a `.c` file into the build via `moon.pkg` native link config. Need to verify the exact `moon.pkg` syntax for linking C sources — check moonbitlang/core for examples.
Acceptance
`DateTime::now()` returns millisecond (or better) precision on all three backends.
Currently `DateTime::now()` on native uses POSIX `time(2)` — whole-second precision only.
Fix
Add a thin C stub calling `clock_gettime(CLOCK_REALTIME)` that returns nanoseconds as `Int64`. Replace the `time(2)` call in `now_native.mbt`.
```c
#include <time.h>
#include <stdint.h>
int64_t tempo_sys_unix_nanos(void) {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
}
```
Requires wiring a `.c` file into the build via `moon.pkg` native link config. Need to verify the exact `moon.pkg` syntax for linking C sources — check moonbitlang/core for examples.
Acceptance
`DateTime::now()` returns millisecond (or better) precision on all three backends.