From 7cebaf0dddc73fa48b3f526b816eabc7674e1c27 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 11 Aug 2016 11:09:48 +0200 Subject: [PATCH] Fixed dates! --- pages/js/index.js | 4 +++- .../github/norbipeti/chat/server/page/IndexPage.java | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pages/js/index.js b/pages/js/index.js index fed71b4..8621e31 100644 --- a/pages/js/index.js +++ b/pages/js/index.js @@ -15,7 +15,9 @@ $(document).ready(function () { if (spans[i].className.split(' ').indexOf("converttime") > -1) ctime = spans[i]; if (ctime != null) - ctime.innerText = moment(ctime.innerText).format("lll"); + console.log(ctime.innerText); + if (ctime != null) + ctime.innerText = moment(ctime.innerText, "YYYY-MM-DDTHH:mm:ssZ").fromNow(); //.format("lll"); //ctime.innerText = new Date(ctime.innerText * 1).toDateString(); } cmsgs.lastElementChild.scrollIntoView(false); diff --git a/src/io/github/norbipeti/chat/server/page/IndexPage.java b/src/io/github/norbipeti/chat/server/page/IndexPage.java index 6c73724..f48a471 100644 --- a/src/io/github/norbipeti/chat/server/page/IndexPage.java +++ b/src/io/github/norbipeti/chat/server/page/IndexPage.java @@ -38,10 +38,10 @@ public class IndexPage extends Page { Element userbox = doc.getElementById("userbox"); userbox.html(userbox.html().replace("", user.getName())); Element channelmessages = doc.getElementById("channelmessages"); - LogManager.getLogger().log(Level.INFO, + LogManager.getLogger().log(Level.DEBUG, "Conversations: " + DataManager.getAll(Conversation.class).size()); - LogManager.getLogger().log(Level.INFO, "User conversations: " + user.getConversations().size()); - LogManager.getLogger().log(Level.INFO, "Username: " + user.getName()); + LogManager.getLogger().log(Level.DEBUG, "User conversations: " + user.getConversations().size()); + LogManager.getLogger().log(Level.DEBUG, "Username: " + user.getName()); if (user.getConversations().size() == 0) { LoaderCollection convs = DataManager.getAll(Conversation.class); if (convs.size() == 0) { @@ -55,7 +55,7 @@ public class IndexPage extends Page { cide.attr("style", "display: none"); cide.attr("id", "convidp"); cide.text(Long.toString(conv.getId())); - LogManager.getLogger().log(Level.INFO, "Messages: " + conv.getMesssageChunks().size()); + LogManager.getLogger().log(Level.DEBUG, "Messages: " + conv.getMesssageChunks().size()); for (MessageChunk chunk : conv.getMesssageChunks()) { // TODO: Reverse for (Message message : chunk.getMessages()) { Element msgelement = channelmessages.appendElement("div"); @@ -63,7 +63,8 @@ public class IndexPage extends Page { header.text(message.getSender().get().getName() + " - "); SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); isoFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - header.appendElement("span").addClass("converttime").text(isoFormat.format(message.getTime())); + header.appendElement("span").addClass("converttime") + .text(isoFormat.format(message.getTime()) + "+00:00"); Element body = msgelement.appendElement("p"); body.text(message.getMessage()); // TODO: Use JavaScript to convert time }