Userland: Add functionality of changing system date in date utility

This commit is contained in:
Liav A 2020-03-13 01:19:56 +02:00 committed by Andreas Kling
parent 64c73d0739
commit b2585b3577
Notes: sideshowbarker 2024-07-19 08:14:14 +09:00

View file

@ -43,6 +43,15 @@ int main(int argc, char** argv)
printf("%lld\n", now);
return 0;
}
if (argc == 3 && !strcmp(argv[1], "-s")) {
bool ok;
timespec ts = { String(argv[2]).to_uint(ok), 0 };
if (!ok) {
printf("date: Invalid timestamp value\n");
return 1;
}
return clock_settime(CLOCK_REALTIME, &ts);
}
printf("%s\n", Core::DateTime::from_timestamp(now).to_string().characters());
return 0;