mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
timezone: Add a command line utility to set the system time zone
This commit is contained in:
committed by
Linus Groh
parent
2bdc3aec42
commit
6057a2ca30
@@ -101,6 +101,10 @@ if [ -f mnt/bin/utmpupdate ]; then
|
|||||||
chown 0:$utmp_gid mnt/bin/utmpupdate
|
chown 0:$utmp_gid mnt/bin/utmpupdate
|
||||||
chmod 2755 mnt/bin/utmpupdate
|
chmod 2755 mnt/bin/utmpupdate
|
||||||
fi
|
fi
|
||||||
|
if [ -f mnt/bin/timezone ]; then
|
||||||
|
chown 0:$phys_gid mnt/bin/timezone
|
||||||
|
chmod 4750 mnt/bin/timezone
|
||||||
|
fi
|
||||||
if [ -f mnt/usr/Tests/Kernel/TestMemoryDeviceMmap ]; then
|
if [ -f mnt/usr/Tests/Kernel/TestMemoryDeviceMmap ]; then
|
||||||
chown 0:0 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
chown 0:0 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
||||||
chmod 4755 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
chmod 4755 mnt/usr/Tests/Kernel/TestMemoryDeviceMmap
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ target_link_libraries(telws LibProtocol LibLine)
|
|||||||
target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell)
|
target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell)
|
||||||
target_link_libraries(test-imap LibIMAP LibMain)
|
target_link_libraries(test-imap LibIMAP LibMain)
|
||||||
target_link_libraries(test-pthread LibThreading)
|
target_link_libraries(test-pthread LibThreading)
|
||||||
|
target_link_libraries(timezone LibMain)
|
||||||
target_link_libraries(top LibMain)
|
target_link_libraries(top LibMain)
|
||||||
target_link_libraries(touch LibMain)
|
target_link_libraries(touch LibMain)
|
||||||
target_link_libraries(truncate LibMain)
|
target_link_libraries(truncate LibMain)
|
||||||
|
|||||||
33
Userland/Utilities/timezone.cpp
Normal file
33
Userland/Utilities/timezone.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Tim Flynn <trflynn89@pm.me>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/StringView.h>
|
||||||
|
#include <AK/Try.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
|
#include <LibTimeZone/TimeZone.h>
|
||||||
|
|
||||||
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
{
|
||||||
|
TRY(Core::System::pledge("stdio rpath wpath cpath"));
|
||||||
|
TRY(Core::System::unveil("/etc/timezone", "rwc"));
|
||||||
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
|
StringView time_zone;
|
||||||
|
|
||||||
|
Core::ArgsParser args_parser;
|
||||||
|
args_parser.add_positional_argument(time_zone, "The time zone to set", "time-zone", Core::ArgsParser::Required::No);
|
||||||
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
if (time_zone.is_empty()) {
|
||||||
|
outln("{}", TimeZone::current_time_zone());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRY(TimeZone::change_time_zone(time_zone));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user