Use utc time everywhere

This commit is contained in:
fiaxh 2017-08-31 18:40:58 +02:00
parent a257b16337
commit d2a5287eff
14 changed files with 32 additions and 32 deletions

View file

@ -54,7 +54,7 @@ public class Conversation : Object {
counterpart = resource != null ? new Jid.with_resource(jid, resource) : new Jid(jid);
active = row[db.conversation.active];
int64? last_active = row[db.conversation.last_active];
if (last_active != null) this.last_active = new DateTime.from_unix_local(last_active);
if (last_active != null) this.last_active = new DateTime.from_unix_utc(last_active);
type_ = (Conversation.Type) row[db.conversation.type_];
encryption = (Encryption) row[db.conversation.encryption];
int? read_up_to = row[db.conversation.read_up_to];

View file

@ -52,8 +52,8 @@ public class FileTransfer : Object {
ourpart = account.bare_jid;
}
direction = row[db.file_transfer.direction];
time = new DateTime.from_unix_local(row[db.file_transfer.time]);
local_time = new DateTime.from_unix_local(row[db.file_transfer.time]);
time = new DateTime.from_unix_utc(row[db.file_transfer.time]);
local_time = new DateTime.from_unix_utc(row[db.file_transfer.time]);
encryption = (Encryption) row[db.file_transfer.encryption];
file_name = row[db.file_transfer.file_name];
path = row[db.file_transfer.path];

View file

@ -73,8 +73,8 @@ public class Message : Object {
ourpart = account.bare_jid;
}
direction = row[db.message.direction];
time = new DateTime.from_unix_local(row[db.message.time]);
local_time = new DateTime.from_unix_local(row[db.message.time]);
time = new DateTime.from_unix_utc(row[db.message.time]);
local_time = new DateTime.from_unix_utc(row[db.message.time]);
body = row[db.message.body];
marked = (Message.Marked) row[db.message.marked];
encryption = (Encryption) row[db.message.encryption];

View file

@ -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);
}

View file

@ -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) => {

View file

@ -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) {

View file

@ -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}) {

View file

@ -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<Jid, ArrayList<Show>>? 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<Jid, ArrayList<Show>>();

View file

@ -56,7 +56,7 @@ public abstract class ConversationRow : ListBoxRow {
Entities.Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_last_message(conversation);
if (message != null) {
update_message(message.body.replace("\n", " "));
update_time(message.time.to_local());
update_time(message.time.to_utc());
}
}
@ -163,7 +163,7 @@ public abstract class ConversationRow : ListBoxRow {
}
private static string get_relative_time(DateTime datetime) {
DateTime now = new DateTime.now_local();
DateTime now = new DateTime.now_utc();
TimeSpan timespan = now.difference(datetime);
if (timespan > 365 * TimeSpan.DAY) {
return datetime.get_year().to_string();

View file

@ -134,11 +134,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
Dino.Application app = Dino.Application.get_default();
if (item_skeletons.size == 1) {
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
populator.populate_between_widgets(conversation, item.sort_time, new DateTime.now_utc());
populator.populate_timespan(conversation, item.sort_time, new DateTime.now_utc());
}
} else {
foreach (Plugins.ConversationItemPopulator populator in app.plugin_registry.conversation_item_populators) {
populator.populate_between_widgets(conversation, item.sort_time, meta_items.higher(item).sort_time);
populator.populate_timespan(conversation, item.sort_time, meta_items.higher(item).sort_time);
}
}
}

View file

@ -31,15 +31,15 @@ class FilePopulator : Plugins.ConversationItemPopulator, Object {
public void close(Conversation conversation) { }
public void populate_timespan(Conversation conversation, DateTime from, DateTime to) { }
public void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) {
public void populate_timespan(Conversation conversation, DateTime from, DateTime to) {
Gee.List<FileTransfer> transfers = stream_interactor.get_module(FileManager.IDENTITY).get_file_transfers(conversation.account, conversation.counterpart, from, to);
foreach (FileTransfer transfer in transfers) {
insert_file(transfer);
}
}
public void populate_between_widgets(Conversation conversation, DateTime from, DateTime to) { }
private void insert_file(FileTransfer transfer) {
if (transfer.mime_type.has_prefix("image")) {
item_collection.insert_item(new ImageItem(stream_interactor, transfer));

View file

@ -126,7 +126,7 @@ public static bool is_dark_theme(Gtk.Widget widget) {
public static bool is_24h_format() {
GLib.Settings settings = new GLib.Settings("org.gnome.desktop.interface");
string settings_format = settings.get_string("clock-format");
string p_format = (new DateTime.now_local()).format("%p");
string p_format = (new DateTime.now_utc()).format("%p");
return settings_format == "24h" || p_format == " ";
}

View file

@ -34,7 +34,7 @@ public class Context {
}
public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error {
if (timestamp == 0) timestamp = new DateTime.now_local().to_unix();
if (timestamp == 0) timestamp = new DateTime.now_utc().to_unix();
SignedPreKeyRecord res;
throw_by_code(Protocol.KeyHelper.generate_signed_pre_key(out res, identity_key_pair, id, timestamp, native_context));
return res;

View file

@ -95,7 +95,7 @@ class SessionBuilderTest : Gee.TestCase {
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
bob_store.store_pre_key(bob_pre_key_record);
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
/* Create Bob's session cipher and decrypt the message from Alice */
@ -163,7 +163,7 @@ class SessionBuilderTest : Gee.TestCase {
bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
bob_store.store_pre_key(bob_pre_key_record);
bob_signed_pre_key_record = new SignedPreKeyRecord(23, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
bob_signed_pre_key_record = new SignedPreKeyRecord(23, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
/* Have Alice process Bob's pre key bundle */
@ -262,7 +262,7 @@ class SessionBuilderTest : Gee.TestCase {
/* Add Bob's pre keys to Bob's data store */
PreKeyRecord bob_pre_key_record = new PreKeyRecord(bob_pre_key.pre_key_id, bob_pre_key_pair);
bob_store.store_pre_key(bob_pre_key_record);
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_local().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
SignedPreKeyRecord bob_signed_pre_key_record = new SignedPreKeyRecord(22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature);
bob_store.store_signed_pre_key(bob_signed_pre_key_record);
/*