From d2a5287effcf60a44084568a37c9c9091d336178 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 31 Aug 2017 18:40:58 +0200 Subject: Use utc time everywhere --- libdino/src/service/chat_interaction.vala | 8 ++++---- libdino/src/service/connection_manager.vala | 2 +- libdino/src/service/conversation_manager.vala | 2 +- libdino/src/service/message_processor.vala | 6 +++--- libdino/src/service/presence_manager.vala | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'libdino/src/service') diff --git a/libdino/src/service/chat_interaction.vala b/libdino/src/service/chat_interaction.vala index 3e8f4b24..0aefc418 100644 --- a/libdino/src/service/chat_interaction.vala +++ b/libdino/src/service/chat_interaction.vala @@ -51,8 +51,8 @@ public class ChatInteraction : StreamInteractionModule, Object { if (!last_input_interaction.has_key(conversation)) { send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_COMPOSING); } - last_input_interaction[conversation] = new DateTime.now_local(); - last_interface_interaction[conversation] = new DateTime.now_local(); + last_input_interaction[conversation] = new DateTime.now_utc(); + last_interface_interaction[conversation] = new DateTime.now_utc(); } public void on_message_cleared(Conversation? conversation) { @@ -106,7 +106,7 @@ public class ChatInteraction : StreamInteractionModule, Object { if (!iter.valid && iter.has_next()) iter.next(); Conversation conversation = iter.get_key(); if (last_input_interaction.has_key(conversation) && - (new DateTime.now_local()).difference(last_input_interaction[conversation]) >= 15 * TimeSpan.SECOND) { + (new DateTime.now_utc()).difference(last_input_interaction[conversation]) >= 15 * TimeSpan.SECOND) { iter.unset(); send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_PAUSED); } @@ -115,7 +115,7 @@ public class ChatInteraction : StreamInteractionModule, Object { if (!iter.valid && iter.has_next()) iter.next(); Conversation conversation = iter.get_key(); if (last_interface_interaction.has_key(conversation) && - (new DateTime.now_local()).difference(last_interface_interaction[conversation]) >= 1.5 * TimeSpan.MINUTE) { + (new DateTime.now_utc()).difference(last_interface_interaction[conversation]) >= 1.5 * TimeSpan.MINUTE) { iter.unset(); send_chat_state_notification(conversation, Xep.ChatStateNotifications.STATE_GONE); } diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala index f7333bbd..2be16a21 100644 --- a/libdino/src/service/connection_manager.vala +++ b/libdino/src/service/connection_manager.vala @@ -155,7 +155,7 @@ public class ConnectionManager { } stream.log = new Core.XmppLog(account.bare_jid.to_string(), log_options); - Connection connection = new Connection(stream, new DateTime.now_local()); + Connection connection = new Connection(stream, new DateTime.now_utc()); connections[account] = connection; change_connection_state(account, ConnectionState.CONNECTING); stream.attached_modules.connect((stream) => { diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala index 81d846e0..0f827e26 100644 --- a/libdino/src/service/conversation_manager.vala +++ b/libdino/src/service/conversation_manager.vala @@ -86,7 +86,7 @@ public class ConversationManager : StreamInteractionModule, Object { public void start_conversation(Conversation conversation, bool push_front = false) { if (push_front) { - conversation.last_active = new DateTime.now_local(); + conversation.last_active = new DateTime.now_utc(); if (conversation.active) conversation_activated(conversation); } if (!conversation.active) { diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala index 4bb30ce6..25e8f91a 100644 --- a/libdino/src/service/message_processor.vala +++ b/libdino/src/service/message_processor.vala @@ -85,7 +85,7 @@ public class MessageProcessor : StreamInteractionModule, Object { Xep.MessageArchiveManagement.MessageFlag? mam_message_flag = Xep.MessageArchiveManagement.MessageFlag.get_flag(message); if (mam_message_flag != null) new_message.local_time = mam_message_flag.server_time; - if (new_message.local_time == null || new_message.local_time.compare(new DateTime.now_local()) > 0) new_message.local_time = new DateTime.now_local(); + if (new_message.local_time == null || new_message.local_time.compare(new DateTime.now_utc()) > 0) new_message.local_time = new DateTime.now_utc(); Xep.DelayedDelivery.MessageFlag? delayed_message_flag = Xep.DelayedDelivery.MessageFlag.get_flag(message); if (delayed_message_flag != null) new_message.time = delayed_message_flag.datetime; @@ -163,8 +163,8 @@ public class MessageProcessor : StreamInteractionModule, Object { message.stanza_id = random_uuid(); message.account = conversation.account; message.body = text; - message.time = new DateTime.now_local(); - message.local_time = new DateTime.now_local(); + message.time = new DateTime.now_utc(); + message.local_time = new DateTime.now_utc(); message.direction = Entities.Message.DIRECTION_SENT; message.counterpart = conversation.counterpart; if (conversation.type_ in new Conversation.Type[]{Conversation.Type.GROUPCHAT, Conversation.Type.GROUPCHAT_PM}) { diff --git a/libdino/src/service/presence_manager.vala b/libdino/src/service/presence_manager.vala index ad2db89f..298fa234 100644 --- a/libdino/src/service/presence_manager.vala +++ b/libdino/src/service/presence_manager.vala @@ -30,10 +30,10 @@ public class PresenceManager : StreamInteractionModule, Object { if (stream != null) { Xmpp.Presence.Stanza? presence = stream.get_flag(Presence.Flag.IDENTITY).get_presence(jid.to_string()); if (presence != null) { - return new Show(jid, presence.show, new DateTime.now_local()); + return new Show(jid, presence.show, new DateTime.now_utc()); } } - return new Show(jid, Show.OFFLINE, new DateTime.now_local()); + return new Show(jid, Show.OFFLINE, new DateTime.now_utc()); } public HashMap>? get_shows(Jid jid, Account account) { @@ -116,7 +116,7 @@ public class PresenceManager : StreamInteractionModule, Object { } private void add_show(Account account, Jid jid, string s) { - Show show = new Show(jid, s, new DateTime.now_local()); + Show show = new Show(jid, s, new DateTime.now_utc()); lock (shows) { if (!shows.has_key(jid)) { shows[jid] = new HashMap>(); @@ -148,4 +148,4 @@ public class Show : Object { this.datetime = datetime; } } -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2