summaryrefslogtreecommitdiff
path: root/src/util/misc.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/misc.vala')
-rw-r--r--src/util/misc.vala30
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) {