Carson's Travels - 章鱼漫游记

一些关于旅行的东东 | Adventure travel around the world

Test VBA

<!DOCTYPE html>

<html>

<body>

  <table style="width: 50%; margin: 0 auto 20px; border-collapse: collapse; border: 1px solid #ddd;">

    <thead>

      <tr style="background-color: #f2f2f2;">

        <th style="padding: 10px; text-align: center; border: 1px solid #ddd;">Emoji</th>

        <th style="padding: 10px; text-align: center; border: 1px solid #ddd;">Status</th>

      </tr>

    </thead>

    <tbody>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;">😊</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Working Hours</td>

      </tr>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;">😴</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Non-Working Hours</td>

      </tr>

    </tbody>

  </table>


  <table style="width: 80%; margin: 0 auto; border-collapse: collapse; border: 1px solid #ddd;">

    <thead>

      <tr style="background-color: #f2f2f2;">

        <th style="width: 15%; padding: 10px; text-align: center; border: 1px solid #ddd;">Region</th>

        <th style="width: 17%; padding: 10px; text-align: center; border: 1px solid #ddd;">US (EST)</th>

        <th style="width: 17%; padding: 10px; text-align: center; border: 1px solid #ddd;">UK (GMT/BST)</th>

        <th style="width: 17%; padding: 10px; text-align: center; border: 1px solid #ddd;">Poland (CET/CEST)</th>

        <th style="width: 17%; padding: 10px; text-align: center; border: 1px solid #ddd;">India (IST)</th>

        <th style="width: 17%; padding: 10px; text-align: center; border: 1px solid #ddd;">China (CST)</th>

      </tr>

    </thead>

    <tbody>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Timezone</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">GMT -5<br>DST: GMT -4</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">GMT +0<br>DST: GMT +1</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">GMT +1<br>DST: GMT +2</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">GMT +5:30</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">GMT +8</td>

      </tr>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Time</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;" id="time-us"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;" id="time-uk"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;" id="time-poland"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;" id="time-india"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;" id="time-china"></td>

      </tr>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Status</td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;" id="work-status-us"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;" id="work-status-uk"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;" id="work-status-poland"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;" id="work-status-india"></td>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd; font-size: 32px;" id="work-status-china"></td>

      </tr>

      <tr>

        <td style="padding: 10px; text-align: center; border: 1px solid #ddd;">Time Adjustment</td>

        <td style="padding: 15px 0; text-align: center; border: 1px solid #ddd;" colspan="5">

          <span style="margin-right: 10px;">-12</span>

          <input type="range" id="slider" min="-720" max="720" step="1" value="0" style="width: 80%;">

          <span style="margin-left: 10px;">+12</span>

        </td>

      </tr>

    </tbody>

  </table>


  <div style="text-align: center; margin-top: 20px;">

    <button onclick="resetTime()" style="padding: 10px 20px; font-size: 16px;">Back to current time</button>

  </div>


  <script>

    let offsetMinutes = 0;


    function updateTimes() {

      const currentTime = new Date();

      const adjustedTime = new Date(currentTime.getTime() + offsetMinutes * 60 * 1000);


      const timeZones = {

        'time-us': { timeZone: 'America/New_York', workStart: 9, workEnd: 18, iconId: 'work-status-us' },

        'time-uk': { timeZone: 'Europe/London', workStart: 9, workEnd: 18, iconId: 'work-status-uk' },

        'time-poland': { timeZone: 'Europe/Warsaw', workStart: 9, workEnd: 18, iconId: 'work-status-poland' },

        'time-india': { timeZone: 'Asia/Kolkata', workStart: 9, workEnd: 18, iconId: 'work-status-india' },

        'time-china': { timeZone: 'Asia/Shanghai', workStart: 9, workEnd: 18, iconId: 'work-status-china' }

      };


      for (let id in timeZones) {

        const tz = timeZones[id];

        const tzTime = new Date(adjustedTime.toLocaleString('en-US', { timeZone: tz.timeZone }));

        const hours = tzTime.getHours();

        const hours24 = hours.toString().padStart(2, '0');

        const minutes = tzTime.getMinutes().toString().padStart(2, '0');

        const seconds = tzTime.getSeconds().toString().padStart(2, '0');

        const hours12 = ((hours + 11) % 12 + 1);

        const amPm = hours >= 12 ? 'PM' : 'AM';


        document.getElementById(id).textContent = `${hours24}:${minutes}:${seconds} (${hours12}:${minutes}:${seconds} ${amPm})`;


        document.getElementById(tz.iconId).textContent = (hours >= tz.workStart && hours < tz.workEnd) ? '😊' : '😴';

      }

    }


    function resetTime() {

      offsetMinutes = 0;

      document.getElementById('slider').value = 0;

      updateTimes();

    }


    document.getElementById('slider').addEventListener('input', function() {

      offsetMinutes = parseInt(this.value);

      updateTimes();

    });


    setInterval(updateTimes, 1000);

    updateTimes();

  </script>

</body>

</html>


Powered By Z-BlogPHP 1.7.3

2024 Carson's Travels - 章鱼漫游记 - WWW.CARSONX.COM All Rights Reserved.