diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
commit | b86540b743f1a87a163ffb811c8fe22a01fefa38 (patch) | |
tree | b47cb3bb83c2377234226fb3987ab3320a987dd9 /src/util/misc.vala | |
parent | ac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff) | |
parent | e905d8e16eec152d19797937f13ba3cf4b8f8aca (diff) |
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'src/util/misc.vala')
-rw-r--r-- | src/util/misc.vala | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/util/misc.vala b/src/util/misc.vala index 6111ea3..2106621 100644 --- a/src/util/misc.vala +++ b/src/util/misc.vala @@ -54,22 +54,12 @@ public bool int_value_equals(Value a, Value b) { return (int) a == (int) b; } -public ulong timeval_to_ms(TimeVal time_val) { - return (((ulong) time_val.tv_sec) * 1000) + (((ulong) time_val.tv_usec) / 1000); -} - public ulong now_ms() { - return timeval_to_ms(TimeVal()); -} - -public ulong now_sec() { - TimeVal time_val = TimeVal(); - - return time_val.tv_sec; + return (ulong) (GLib.get_real_time() / 1000); } -public inline time_t now_time_t() { - return (time_t) now_sec(); +public int64 now_sec() { + return (ulong) (GLib.get_real_time() / Util.USEC_PER_SEC); } public string md5_file(File file) throws Error { @@ -216,14 +206,16 @@ public Gee.List<MediaSource>? unserialize_media_sources(uchar* serialized, int s return list; } -public string format_local_datespan(Time from_date, Time to_date) { +public string format_local_datespan(DateTime from_date, DateTime to_date) { string from_format, to_format; // Ticket #3240 - Change the way date ranges are pretty- // printed if the start and end date occur on consecutive days. - if (from_date.year == to_date.year) { + if (from_date.get_year() == to_date.get_year()) { // are these consecutive dates? - if ((from_date.month == to_date.month) && (from_date.day == (to_date.day - 1))) { + // get_day_of_year() looks like it saves a bit of code, but then we would + // not recognize the change of months + if ((from_date.get_month() == to_date.get_month()) && (from_date.get_day_of_month() == (to_date.get_day_of_month() - 1))) { // Yes; display like so: Sat, July 4 - 5, 20X6 from_format = Resources.get_start_multiday_span_format_string(); to_format = Resources.get_end_multiday_span_format_string(); @@ -244,7 +236,7 @@ public string format_local_datespan(Time from_date, Time to_date) { to_date.format(to_format))); } -public string format_local_date(Time date) { +public string format_local_date(DateTime date) { return String.strip_leading_zeroes(date.format(Resources.get_long_date_format_string())); } @@ -273,7 +265,9 @@ public class OneShotScheduler { } public void at_idle() { - at_priority_idle(Priority.DEFAULT_IDLE); + // needs to be lower (higher priority) than Clutter.PRIORITY_REDRAW which is + // set at Priority.HIGH_IDLE + 50 + at_priority_idle(Priority.HIGH_IDLE + 40); } public void at_priority_idle(int priority) { |