Browse Source

Added readable UTC timestamp to database and displayMode

Nathan Schneider 4 years ago
parent
commit
5da3815470
1 changed files with 14 additions and 5 deletions
  1. 14 5
      _layouts/rule.html

+ 14 - 5
_layouts/rule.html

@@ -228,12 +228,17 @@ These are the major functional buttons*/
   // Publishes existing fields to new page, /create/?rule=[ruleID]
   // Opens new page in Display mode
   function publishRule() {
-      var time = new Date();
-      var timestamp = time.getTime();
+      var now = new Date();
+      // Numerical ID for published Rule
+      var timeID = now.getTime();
+      // Readable UTC timestamp
+      var dateTime = now.getUTCFullYear()+'.'+(now.getUTCMonth()+1)+'.'+now.getUTCDate()
+          +' '+now.getUTCHours()+":"+ now.getUTCMinutes()+":"+now.getUTCSeconds()
+          + ' UTC';
       // TKTK: Check if ruleID exists; while yes, replace and repeat
       var rule = [{
-          ruleID: timestamp,
-          timestamp: time.toISOString(),
+          ruleID: timeID,
+          timestamp: dateTime,
       }];
       var fields = document.getElementsByClassName("editable");
       for (var i = 0; i < fields.length; i++) {
@@ -245,7 +250,7 @@ These are the major functional buttons*/
           "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
       );
       store.append("rules", rule).then(data => {
-          window.open("/create/?r=" + timestamp, "_self", false);
+          window.open("/create/?r=" + timeID, "_self", false);
       });
   }
 
@@ -267,6 +272,9 @@ These are the major functional buttons*/
               }
               document.getElementById(key).innerHTML = value;
           }
+          // Publish timestamp to Rule
+          document.getElementById('dateTime').innerHTML = rule['timestamp'];
+          // Finish
           displayMode = false;
           toggleDisplayMode();
           document.title = rule['communityname'] + " / CommunityRule";
@@ -432,6 +440,7 @@ These are the major functional buttons*/
     <br />
     <p><a href="http://communityrule.info">
         <img src="https://img.shields.io/badge/CommunityRule-derived-000000" alt="CommunityRule derived"></a></p>
+    <p id="dateTime"></p>
     <p>Created with <a href="http://communityrule.info">CommunityRule</a><br />
       <a href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
     <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>