35
35
#include " vm/cells/MerkleProof.h"
36
36
#include " block/mc-config.h"
37
37
#include " ton/ton-shard.h"
38
+ #include " td/utils/date.h"
38
39
39
40
bool local_scripts{false };
40
41
42
+ static std::string time_to_human (unsigned ts) {
43
+ td::StringBuilder sb;
44
+ sb << date::format (" %F %T" ,
45
+ std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>{std::chrono::seconds (ts)})
46
+ << " , " ;
47
+ auto now = (unsigned )td::Clocks::system ();
48
+ bool past = now >= ts;
49
+ unsigned x = past ? now - ts : ts - now;
50
+ if (!past) {
51
+ sb << " in " ;
52
+ }
53
+ if (x < 60 ) {
54
+ sb << x << " s" ;
55
+ } else if (x < 3600 ) {
56
+ sb << x / 60 << " m " << x % 60 << " s" ;
57
+ } else if (x < 3600 * 24 ) {
58
+ x /= 60 ;
59
+ sb << x / 60 << " h " << x % 60 << " m" ;
60
+ } else {
61
+ x /= 3600 ;
62
+ sb << x / 24 << " d " << x % 24 << " h" ;
63
+ }
64
+ if (past) {
65
+ sb << " ago" ;
66
+ }
67
+ return sb.as_cslice ().str ();
68
+ }
69
+
41
70
HttpAnswer& HttpAnswer::operator <<(AddressCell addr_c) {
42
71
ton::WorkchainId wc;
43
72
ton::StdSmcAddress addr;
@@ -84,7 +113,7 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
84
113
<< " <tr><th>source</th><td>" << AddressCell{info.src } << " </td></tr>\n "
85
114
<< " <tr><th>destination</th><td>NONE</td></tr>\n "
86
115
<< " <tr><th>lt</th><td>" << info.created_lt << " </td></tr>\n "
87
- << " <tr><th>time</th><td>" << info.created_at << " </td></tr>\n " ;
116
+ << " <tr><th>time</th><td>" << info.created_at << " ( " << time_to_human (info. created_at ) << " ) </td></tr>\n " ;
88
117
break ;
89
118
}
90
119
case block::gen::CommonMsgInfo::int_msg_info: {
@@ -103,7 +132,7 @@ HttpAnswer& HttpAnswer::operator<<(MessageCell msg) {
103
132
<< " <tr><th>source</th><td>" << AddressCell{info.src } << " </td></tr>\n "
104
133
<< " <tr><th>destination</th><td>" << AddressCell{info.dest } << " </td></tr>\n "
105
134
<< " <tr><th>lt</th><td>" << info.created_lt << " </td></tr>\n "
106
- << " <tr><th>time</th><td>" << info.created_at << " </td></tr>\n "
135
+ << " <tr><th>time</th><td>" << info.created_at << " ( " << time_to_human (info. created_at ) << " ) </td></tr>\n "
107
136
<< " <tr><th>value</th><td>" << value << " </td></tr>\n " ;
108
137
break ;
109
138
}
@@ -277,7 +306,7 @@ HttpAnswer& HttpAnswer::operator<<(TransactionCell trans_c) {
277
306
<< " <tr><th>account</th><td>" << trans_c.addr .rserialize (true ) << " </td></tr>"
278
307
<< " <tr><th>hash</th><td>" << trans_c.root ->get_hash ().to_hex () << " </td></tr>\n "
279
308
<< " <tr><th>lt</th><td>" << trans.lt << " </td></tr>\n "
280
- << " <tr><th>time</th><td>" << trans.now << " </td></tr>\n "
309
+ << " <tr><th>time</th><td>" << trans.now << " ( " << time_to_human (trans. now ) << " ) </td></tr>\n "
281
310
<< " <tr><th>out messages</th><td>" ;
282
311
vm::Dictionary dict{trans.r1 .out_msgs , 15 };
283
312
for (td::int32 i = 0 ; i < trans.outmsg_cnt ; i++) {
@@ -456,7 +485,7 @@ HttpAnswer& HttpAnswer::operator<<(BlockHeaderCell head_c) {
456
485
<< " <tr><th>block</th><td>" << block_id.id .to_str () << " </td></tr>\n "
457
486
<< " <tr><th>roothash</th><td>" << block_id.root_hash .to_hex () << " </td></tr>\n "
458
487
<< " <tr><th>filehash</th><td>" << block_id.file_hash .to_hex () << " </td></tr>\n "
459
- << " <tr><th>time</th><td>" << info.gen_utime << " </td></tr>\n "
488
+ << " <tr><th>time</th><td>" << info.gen_utime << " ( " << time_to_human (info. gen_utime ) << " ) </td></tr>\n "
460
489
<< " <tr><th>lt</th><td>" << info.start_lt << " .. " << info.end_lt << " </td></tr>\n "
461
490
<< " <tr><th>global_id</th><td>" << blk.global_id << " </td></tr>\n "
462
491
<< " <tr><th>version</th><td>" << info.version << " </td></tr>\n "
@@ -543,7 +572,8 @@ HttpAnswer& HttpAnswer::operator<<(BlockShardsCell shards_c) {
543
572
ton::ShardIdFull shard{id.workchain , id.shard };
544
573
if (ref.not_null ()) {
545
574
*this << " <td>" << shard.to_str () << " </td><td><a href=\" " << HttpAnswer::BlockLink{ref->top_block_id ()}
546
- << " \" >" << ref->top_block_id ().id .seqno << " </a></td><td>" << ref->created_at () << " </td>"
575
+ << " \" >" << ref->top_block_id ().id .seqno << " </a></td><td><span title=\" "
576
+ << time_to_human (ref->created_at ()) << " \" >" << ref->created_at () << " </span></td>"
547
577
<< " <td>" << ref->want_split_ << " </td>"
548
578
<< " <td>" << ref->want_merge_ << " </td>"
549
579
<< " <td>" << ref->before_split_ << " </td>"
0 commit comments