elementary / elementary/granite

is_12h: Make Granite use defaults from desktop settings

Open
#525 1 comment 0 reactions 0 assignees View on GitHub
Needs Design Priority: Wishlist
Dominant language
Vala
Stars
329
Forks
65
Avg merge
1d 14h
Merged PRs (30d)
31

Description

## Problem

There are quite a lot of places on the desktop where we'd like to display a time to the user. To use the correct format we can use [`Granite.DateTime.get_default_time_format`](https://github.com/elementary/granite/blob/e4a3e839b5513f7e364f1910505518fab1ffa149/lib/DateTime.vala#L24).

However, this function does not provide a reasonable default value for its `is_12h` argument because its hard coded. But in user facing cases we want to respect the time setting of the user so there are a bunch of cases where we need to retrieve the setting and pass the correct value to Granite. Namely Tasks, Calendar and Mail - potentially others:

https://github.com/search?q=org%3Aelementary+get_default_time_format&type=code

## Proposal

The example above is specific to one case, but maybe there are other similar things I'm missing here? If there is more to this than the 24h time format, then it would be beneficial to tell granite it should use the user settings instead of having them hard wired in the code. If the 24h time format is the only one, then it would be great to have its default set to whatever the user is expecting.

## Prior Art

- I've seen there is Granite.Settings - but I'm not sure if that can be used for this case: https://valadoc.org/granite/Granite.Settings.html
- Granite itself already implements a (private) helper function for detecting the right default value for the 24h format: https://github.com/elementary/granite/blob/7190ee81dcd66c2b28445edf2b7baabdb8524add/lib/DateTime.vala#L98-L102

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.