Userland: Add functionality of changing system date in date utility
This commit is contained in:
parent
64c73d0739
commit
b2585b3577
Notes:
sideshowbarker
2024-07-19 08:14:14 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/b2585b35778 Pull-request: https://github.com/SerenityOS/serenity/pull/1396 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/shannonbooth ✅
1 changed files with 9 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue