Template:IxTimeConvert: Difference between revisions

From IxWiki
Jump to navigation Jump to search
Created page with "<span id="ix-time-convert-{{#time:U}}">Loading...</span> <script> (function() { function convertToIxTime(year, month, day) { var epoch = new Date(2020, 9, 4).getTime() / 1000; var inputDate = new Date(year, month - 1, day).getTime() / 1000; var secondsSinceEpoch = inputDate - epoch; var ixTime = Math.floor(secondsSinceEpoch * 4.0 + epoch); var ixDate = new Date(ixTime * 1000); var options = { weekday: "long", year: "numeric", m..."
Tag: 2017 source edit
 
mNo edit summary
Tag: 2017 source edit
Line 1: Line 1:
<span id="ix-time-convert-{{#time:U}}">Loading...</span>
<includeonly>{{#invoke:IxTime|convertToIxTime|{{{1|}}}|{{{2|}}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}}}</includeonly>
<script>
(function() {
  function convertToIxTime(year, month, day) {
    var epoch = new Date(2020, 9, 4).getTime() / 1000;
    var inputDate = new Date(year, month - 1, day).getTime() / 1000;
    var secondsSinceEpoch = inputDate - epoch;
    var ixTime = Math.floor(secondsSinceEpoch * 4.0 + epoch);
    var ixDate = new Date(ixTime * 1000);
    var options = {
      weekday: "long",
      year: "numeric",
      month: "long",
      day: "numeric",
      hour: "2-digit",
      minute: "2-digit",
      second: "2-digit",
      timeZoneName: "short",
    };
    return ixDate.toLocaleString("en-US", options);
  }
 
  var params = "{{1}}|{{2}}|{{3}}".split('|');
  var year = parseInt(params[0]) || new Date().getFullYear();
  var month = parseInt(params[1]) || (new Date().getMonth() + 1);
  var day = parseInt(params[2]) || new Date().getDate();
 
  var result = convertToIxTime(year, month, day);
  document.getElementById("ix-time-convert-{{#time:U}}").textContent = result;
})();
</script>

Revision as of 19:29, 3 August 2024