| git.druid.rocks | index | druid520 | kaboom | src/ | user/ | date.nsc |
src/user/date.nsc
include "syscalls.nsh";
include "stdio.nsh";
/* prints "YYYY-MM-DD HH:MM:SS" from the cmos rtc (syscall 22). no
* timezone (the rtc itself is usually just set to whatever the host
* gave it -- utc under qemu, most of the time), no formatting
* options -- one fixed, sortable format, minimalized like everything
* else here. */
void
print2(u64 val)
{
if(val < (u64)10)
{
putchar((u8)48);
}
put_udec(val);
}
global i32
main(i32 argc, ptr argv)
{
u64 dt[6];
sys_date((ptr)&dt[0]);
put_udec(dt[5]);
putchar((u8)45); /* '-' */
print2(dt[4]);
putchar((u8)45);
print2(dt[3]);
putchar((u8)32); /* ' ' */
print2(dt[2]);
putchar((u8)58); /* ':' */
print2(dt[1]);
putchar((u8)58);
print2(dt[0]);
putchar((u8)10);
stdio_flush();
return 0;
}