diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2021-11-27 22:12:29 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-11 15:10:42 -0800 |
commit | 00dbac9d16c08f618d84db9e04c4083f0688167d (patch) | |
tree | 8ab52959538dc935390c8b97a1b60cf57a359e9a /Userland/Utilities | |
parent | 7b13f22f9619ea41af36fedfed5d886bc1bbdcb6 (diff) | |
download | serenity-00dbac9d16c08f618d84db9e04c4083f0688167d.zip |
date: Port to LibMain :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Utilities/date.cpp | 18 |
2 files changed, 7 insertions, 12 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 612747cbf1..12e52d4b65 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -77,6 +77,7 @@ target_link_libraries(cpp-lexer LibMain) target_link_libraries(cpp-parser LibMain) target_link_libraries(cpp-preprocessor LibMain) target_link_libraries(cut LibMain) +target_link_libraries(date LibMain) target_link_libraries(diff LibDiff) target_link_libraries(disasm LibX86) target_link_libraries(dmesg LibMain) diff --git a/Userland/Utilities/date.cpp b/Userland/Utilities/date.cpp index 965f70ae4e..1298a9ed76 100644 --- a/Userland/Utilities/date.cpp +++ b/Userland/Utilities/date.cpp @@ -7,16 +7,13 @@ #include <AK/String.h> #include <LibCore/ArgsParser.h> #include <LibCore/DateTime.h> -#include <stdio.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> #include <time.h> -#include <unistd.h> -int main(int argc, char** argv) +ErrorOr<int> serenity_main(Main::Arguments arguments) { - if (pledge("stdio settime", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio settime", nullptr)); bool print_unix_date = false; bool print_iso_8601 = false; @@ -30,7 +27,7 @@ int main(int argc, char** argv) args_parser.add_option(print_iso_8601, "Print date in ISO 8601 format", "iso-8601", 'i'); args_parser.add_option(print_rfc_3339, "Print date in RFC 3339 format", "rfc-3339", 'r'); args_parser.add_option(print_rfc_5322, "Print date in RFC 5322 format", "rfc-5322", 'R'); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (set_date != nullptr) { auto number = String(set_date).to_uint(); @@ -41,10 +38,7 @@ int main(int argc, char** argv) } timespec ts = { number.value(), 0 }; - if (clock_settime(CLOCK_REALTIME, &ts) < 0) { - perror("clock_settime"); - return 1; - } + TRY(Core::System::clock_settime(CLOCK_REALTIME, &ts)); return 0; } |