Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/DateTime.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
* getting the default translated format for either date and time.
*/
namespace Granite.DateTime {

[DBus (name = "org.freedesktop.portal.Settings")]
private interface FDO.Portal.Settings : Object {
public abstract Variant read (string @namespace, string key);
}

/**
* Gets a default translated time format.
* The function constructs a new string interpreting the //is_12h// and //with_second// parameters
Expand Down Expand Up @@ -96,8 +102,16 @@ namespace Granite.DateTime {
* @return true if the clock format is 12h based, false otherwise.
*/
private static bool is_clock_format_12h () {
var h24_settings = new GLib.Settings ("org.gnome.desktop.interface");
var format = h24_settings.get_string ("clock-format");
FDO.Portal.Settings settings_bus = GLib.Bus.get_proxy_sync (
GLib.BusType.SESSION,
"org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop"
);

var clock_format_variant = settings_bus.read ("org.gnome.desktop.interface", "clock-format").get_variant ();
var format = clock_format_variant.get_string ();


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint

Suggested change

return (format.contains ("12h"));
}

Expand Down