Finch/tests/new/std_time_proc.fch
Nexoniarz 750eca3e85 --target: windows, linux, arm64, macos or a triple, in the compiler written in Finch
Targets, the target's C compiler (FINCH_CC) for linking, C import for the target (--target to libclang, its
headers), the AAPCS64 and Microsoft x64 ways of passing structs by value (and the System V one),
dllexport for libraries on Windows, .exe names, and running the program through wine or qemu-aarch64.
std/ gets time_windows.fch and proc_windows.fch: a module has a version per system (name_windows.fch,
name_macos.fch, name_linux.fch) that wins over name.fch. stdin, stdout and stderr work where C makes them macros.

Run for real: all 27 programs under tests/run and tests/new pass on ARM64 Linux under qemu and on Windows
under Wine (MinGW), structs by value and callbacks included. macOS is only checked as far as clang accepts the
IR; there is no emulator for it here.
2026-10-25 21:33:19 +01:00

19 lines
765 B
Text

import time
import proc
fn main() -> ! {
d := time.date(86400 * 365 + 3661)
print(d.year, d.month, d.day, d.hour, d.minute, d.second, d.weekday, d.yearday)
print(time.days_in_month(2024, 2), time.days_in_month(2023, 2), time.days_in_month(1900, 2), time.days_in_month(2000, 2), time.days_in_month(2024, 4))
a := time.millis()
time.sleep(30)
waited := time.millis() - a
print(waited >= 20 && waited < 500)
print(time.now() > 1700000000, time.format(0, "%Y") == "1970" || time.format(0, "%Y") == "1969")
print((try proc.output("echo hello")).trim())
print(proc.run("exit 3"))
bad := proc.output("exit 2") or err
print(bad)
print(proc.env("FINCH_SURELY_NOT_SET", "fallback"), proc.pid() > 0, proc.cwd().len > 0)
}