Fossil SCM

For the chat function, the server-to-client JSON uses strict ISO8601 time strings, including the "T" in the middle and the "Z" at the end.

drh 2020-12-25 20:30 trunk
Commit 13c95f0c7537746cf7d7b1a2226d86c2b1ee136c20615c801f0d309f2264a117
2 files changed +2 -1 +2 -2
+2 -1
--- src/chat.c
+++ src/chat.c
@@ -457,11 +457,12 @@
457457
int iToDel = db_column_int(&q1, 7);
458458
char *zMsg;
459459
if(cnt++){
460460
blob_append(&json, ",\n", 2);
461461
}
462
- blob_appendf(&json, "{\"msgid\":%d,\"mtime\":%!j,", id, zDate);
462
+ blob_appendf(&json, "{\"msgid\":%d,", id);
463
+ blob_appendf(&json, "\"mtime\":\"%.10sT%sZ\",", zDate, zDate+11);
463464
blob_appendf(&json, "\"xfrom\":%!j,", zFrom);
464465
blob_appendf(&json, "\"uclr\":%!j,", hash_color(zFrom));
465466
466467
zMsg = chat_format_to_html(zRawMsg ? zRawMsg : "");
467468
blob_appendf(&json, "\"xmsg\":%!j,", zMsg);
468469
--- src/chat.c
+++ src/chat.c
@@ -457,11 +457,12 @@
457 int iToDel = db_column_int(&q1, 7);
458 char *zMsg;
459 if(cnt++){
460 blob_append(&json, ",\n", 2);
461 }
462 blob_appendf(&json, "{\"msgid\":%d,\"mtime\":%!j,", id, zDate);
 
463 blob_appendf(&json, "\"xfrom\":%!j,", zFrom);
464 blob_appendf(&json, "\"uclr\":%!j,", hash_color(zFrom));
465
466 zMsg = chat_format_to_html(zRawMsg ? zRawMsg : "");
467 blob_appendf(&json, "\"xmsg\":%!j,", zMsg);
468
--- src/chat.c
+++ src/chat.c
@@ -457,11 +457,12 @@
457 int iToDel = db_column_int(&q1, 7);
458 char *zMsg;
459 if(cnt++){
460 blob_append(&json, ",\n", 2);
461 }
462 blob_appendf(&json, "{\"msgid\":%d,", id);
463 blob_appendf(&json, "\"mtime\":\"%.10sT%sZ\",", zDate, zDate+11);
464 blob_appendf(&json, "\"xfrom\":%!j,", zFrom);
465 blob_appendf(&json, "\"uclr\":%!j,", hash_color(zFrom));
466
467 zMsg = chat_format_to_html(zRawMsg ? zRawMsg : "");
468 blob_appendf(&json, "\"xmsg\":%!j,", zMsg);
469
+2 -2
--- src/chat.js
+++ src/chat.js
@@ -376,11 +376,11 @@
376376
cssClass: ['fossil-tooltip', 'chat-message-popup'],
377377
refresh:function(){
378378
const eMsg = this._eMsg;
379379
if(!eMsg) return;
380380
D.clearElement(this.e);
381
- const d = new Date(eMsg.dataset.timestamp+"Z");
381
+ const d = new Date(eMsg.dataset.timestamp);
382382
if(d.getMinutes().toString()!=="NaN"){
383383
// Date works, render informative timestamps
384384
D.append(this.e,
385385
D.append(D.span(), localTimeString(d)," client-local"),
386386
D.append(D.span(), iso8601ish(d)));
@@ -607,11 +607,11 @@
607607
eWho.setAttribute('align', 'left');
608608
}
609609
eWho.style.backgroundColor = m.uclr;
610610
eWho.classList.add('message-user');
611611
let whoName = m.xfrom;
612
- var d = new Date(m.mtime + "Z");
612
+ var d = new Date(m.mtime);
613613
if( d.getMinutes().toString()!="NaN" ){
614614
/* Show local time when we can compute it */
615615
eWho.append(D.text(whoName+' @ '+
616616
d.getHours()+":"+(d.getMinutes()+100).toString().slice(1,3)
617617
))
618618
--- src/chat.js
+++ src/chat.js
@@ -376,11 +376,11 @@
376 cssClass: ['fossil-tooltip', 'chat-message-popup'],
377 refresh:function(){
378 const eMsg = this._eMsg;
379 if(!eMsg) return;
380 D.clearElement(this.e);
381 const d = new Date(eMsg.dataset.timestamp+"Z");
382 if(d.getMinutes().toString()!=="NaN"){
383 // Date works, render informative timestamps
384 D.append(this.e,
385 D.append(D.span(), localTimeString(d)," client-local"),
386 D.append(D.span(), iso8601ish(d)));
@@ -607,11 +607,11 @@
607 eWho.setAttribute('align', 'left');
608 }
609 eWho.style.backgroundColor = m.uclr;
610 eWho.classList.add('message-user');
611 let whoName = m.xfrom;
612 var d = new Date(m.mtime + "Z");
613 if( d.getMinutes().toString()!="NaN" ){
614 /* Show local time when we can compute it */
615 eWho.append(D.text(whoName+' @ '+
616 d.getHours()+":"+(d.getMinutes()+100).toString().slice(1,3)
617 ))
618
--- src/chat.js
+++ src/chat.js
@@ -376,11 +376,11 @@
376 cssClass: ['fossil-tooltip', 'chat-message-popup'],
377 refresh:function(){
378 const eMsg = this._eMsg;
379 if(!eMsg) return;
380 D.clearElement(this.e);
381 const d = new Date(eMsg.dataset.timestamp);
382 if(d.getMinutes().toString()!=="NaN"){
383 // Date works, render informative timestamps
384 D.append(this.e,
385 D.append(D.span(), localTimeString(d)," client-local"),
386 D.append(D.span(), iso8601ish(d)));
@@ -607,11 +607,11 @@
607 eWho.setAttribute('align', 'left');
608 }
609 eWho.style.backgroundColor = m.uclr;
610 eWho.classList.add('message-user');
611 let whoName = m.xfrom;
612 var d = new Date(m.mtime);
613 if( d.getMinutes().toString()!="NaN" ){
614 /* Show local time when we can compute it */
615 eWho.append(D.text(whoName+' @ '+
616 d.getHours()+":"+(d.getMinutes()+100).toString().slice(1,3)
617 ))
618

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button