7
7
#include < AK/String.h>
8
8
#include < LibCore/ArgsParser.h>
9
9
#include < LibCore/DateTime.h>
10
- #include < stdio.h>
10
+ #include < LibCore/System.h>
11
+ #include < LibMain/Main.h>
11
12
#include < time.h>
12
- #include < unistd.h>
13
13
14
- int main ( int argc, char ** argv )
14
+ ErrorOr< int > serenity_main (Main::Arguments arguments )
15
15
{
16
- if (pledge (" stdio settime" , nullptr ) < 0 ) {
17
- perror (" pledge" );
18
- return 1 ;
19
- }
16
+ TRY (Core::System::pledge (" stdio settime" , nullptr ));
20
17
21
18
bool print_unix_date = false ;
22
19
bool print_iso_8601 = false ;
@@ -30,7 +27,7 @@ int main(int argc, char** argv)
30
27
args_parser.add_option (print_iso_8601, " Print date in ISO 8601 format" , " iso-8601" , ' i' );
31
28
args_parser.add_option (print_rfc_3339, " Print date in RFC 3339 format" , " rfc-3339" , ' r' );
32
29
args_parser.add_option (print_rfc_5322, " Print date in RFC 5322 format" , " rfc-5322" , ' R' );
33
- args_parser.parse (argc, argv );
30
+ args_parser.parse (arguments );
34
31
35
32
if (set_date != nullptr ) {
36
33
auto number = String (set_date).to_uint ();
@@ -41,10 +38,7 @@ int main(int argc, char** argv)
41
38
}
42
39
43
40
timespec ts = { number.value (), 0 };
44
- if (clock_settime (CLOCK_REALTIME, &ts) < 0 ) {
45
- perror (" clock_settime" );
46
- return 1 ;
47
- }
41
+ TRY (Core::System::clock_settime (CLOCK_REALTIME, &ts));
48
42
49
43
return 0 ;
50
44
}
0 commit comments