mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
date: Port to LibMain :^)
This commit is contained in:
parent
7b13f22f96
commit
00dbac9d16
Notes:
sideshowbarker
2024-07-17 22:55:48 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/00dbac9d16c Pull-request: https://github.com/SerenityOS/serenity/pull/11101 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/bgianfo ✅ Reviewed-by: https://github.com/creator1creeper1 ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 7 additions and 12 deletions
|
@ -77,6 +77,7 @@ target_link_libraries(cpp-lexer LibMain)
|
||||||
target_link_libraries(cpp-parser LibMain)
|
target_link_libraries(cpp-parser LibMain)
|
||||||
target_link_libraries(cpp-preprocessor LibMain)
|
target_link_libraries(cpp-preprocessor LibMain)
|
||||||
target_link_libraries(cut LibMain)
|
target_link_libraries(cut LibMain)
|
||||||
|
target_link_libraries(date LibMain)
|
||||||
target_link_libraries(diff LibDiff)
|
target_link_libraries(diff LibDiff)
|
||||||
target_link_libraries(disasm LibX86)
|
target_link_libraries(disasm LibX86)
|
||||||
target_link_libraries(dmesg LibMain)
|
target_link_libraries(dmesg LibMain)
|
||||||
|
|
|
@ -7,16 +7,13 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <stdio.h>
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <time.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) {
|
TRY(Core::System::pledge("stdio settime", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool print_unix_date = false;
|
bool print_unix_date = false;
|
||||||
bool print_iso_8601 = 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_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_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.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) {
|
if (set_date != nullptr) {
|
||||||
auto number = String(set_date).to_uint();
|
auto number = String(set_date).to_uint();
|
||||||
|
@ -41,10 +38,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
timespec ts = { number.value(), 0 };
|
timespec ts = { number.value(), 0 };
|
||||||
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
|
TRY(Core::System::clock_settime(CLOCK_REALTIME, &ts));
|
||||||
perror("clock_settime");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue