Commit 43434043 authored by JC Brand's avatar JC Brand

Store time as iso8601 strings on messages

parent c0aba844
...@@ -129,9 +129,9 @@ ...@@ -129,9 +129,9 @@
    var numericKeys = [1, 4, 5, 6, 7, 10, 11],     var numericKeys = [1, 4, 5, 6, 7, 10, 11],
struct = /^\s*(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}\.?\d*)Z\s*$/.exec(datestr), struct = /^\s*(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}\.?\d*)Z\s*$/.exec(datestr),
minutesOffset = 0, minutesOffset = 0,
i; i, k;
for (i = 0, k; (k = numericKeys[i]); ++i) { for (i = 0; (k = numericKeys[i]); ++i) {
struct[k] = +struct[k] || 0; struct[k] = +struct[k] || 0;
} }
// allow undefined days and months // allow undefined days and months
...@@ -260,9 +260,9 @@ ...@@ -260,9 +260,9 @@
} else { } else {
if (delayed) { if (delayed) {
stamp = $message.find('delay').attr('stamp'); stamp = $message.find('delay').attr('stamp');
time = (new Date(stamp)).toLocaleTimeString().substring(0,5); time = stamp;
} else { } else {
time = (new Date()).toLocaleTimeString().substring(0,5); time = xmppchat.toISOString(new Date());
} }
if (from == xmppchat.connection.bare_jid) { if (from == xmppchat.connection.bare_jid) {
fullname = 'me'; fullname = 'me';
...@@ -333,10 +333,11 @@ ...@@ -333,10 +333,11 @@
} else { } else {
$chat_content.find('div.chat-event').remove(); $chat_content.find('div.chat-event').remove();
// TODO use toJSON here // TODO use toJSON here
var time = xmppchat.parseISO8601(message.get('time')).toLocaleTimeString().substring(0,5);
$chat_content.append( $chat_content.append(
this.message_template({ this.message_template({
'sender': message.get('sender'), 'sender': message.get('sender'),
'time': message.get('time'), 'time': time,
'message': message.get('message'), 'message': message.get('message'),
'username': message.get('fullname'), 'username': message.get('fullname'),
'extra_classes': message.get('delayed') && 'delayed' || '' 'extra_classes': message.get('delayed') && 'delayed' || ''
...@@ -404,7 +405,7 @@ ...@@ -404,7 +405,7 @@
this.model.messages.create({ this.model.messages.create({
fullname: 'me', fullname: 'me',
sender: 'me', sender: 'me',
time: (new Date()).toLocaleTimeString().substring(0,5), time: xmppchat.toISOString(new Date()),
message: text message: text
}); });
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment